Class InvertibleListOp

List operation variant that can be inverted

Hierarchy (view full)

Constructors

Properties

bin: string

The bin the operation will be performed on.

inverted: boolean

Signifies if Operation will be inverted.

Code which determines the operations to be performed on the bins of a record.

ttl?: number

The time-to-live (expiration) of the record in seconds.

There are also special values that can be set in the record ttl:

Value used in the operation.

Methods

  • Set the return type for certain list operations.

    The return type only affects getBy* and removeBy* list operations.

    Parameters

    Returns ListOperation

    const Aerospike = require('aerospike')
    const lists = Aerospike.lists
    const key = new Aerospike.Key('test', 'demo', 'listsTest')
    // INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
    var config = {
    hosts: '192.168.33.10:3000',
    // Timeouts disabled, latency dependent on server location. Configure as needed.
    policies: {
    write : new Aerospike.WritePolicy({socketTimeout : 0, totalTimeout : 0}),
    operate : new Aerospike.OperatePolicy({socketTimeout : 0, totalTimeout : 0})
    }
    }
    Aerospike.connect(config).then(async client => {
    await client.put(key, { list: [32, 5, 85, 16, 22] })
    const ops = [
    lists.getByValueRange('list', 10, 30)
    .andReturn(lists.returnType.VALUE)
    ]
    const result = await client.operate(key, ops)
    console.log('Result:', result.bins.list) // => Result: [ 16, 22 ]
    client.close()
    })
  • By setting the context, the list operation will be executed on a nested list, instead of the bin value itself.

    Parameters

    • contextOrFunction: Function | Context

    Returns ListOperation

    v3.12.0

    const Aerospike = require('aerospike')
    const lists = Aerospike.lists
    const key = new Aerospike.Key('test', 'demo', 'listsTest')
    // INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
    var config = {
    hosts: '192.168.33.10:3000',
    // Timeouts disabled, latency dependent on server location. Configure as needed.
    policies: {
    write : new Aerospike.WritePolicy({socketTimeout : 0, totalTimeout : 0}),
    operate : new Aerospike.OperatePolicy({socketTimeout : 0, totalTimeout : 0})
    }
    }
    Aerospike.connect(config).then(async (client) => {
    await client.put(key, { list: [[32, 5, 85], [16, 22]] })
    const ops = [
    lists.get('list', 0)
    .withContext((ctx) => ctx.addListIndex(1))
    ]
    const result = await client.operate(key, ops)
    console.log('Result:', result.bins.list) // => Result: 16
    client.close()
    })
    const Aerospike = require('aerospike')
    const lists = Aerospike.lists
    const Context = Aerospike.cdt.Context
    const key = new Aerospike.Key('test', 'demo', 'listsTest')
    // INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
    var config = {
    hosts: '192.168.33.10:3000',
    // Timeouts disabled, latency dependent on server location. Configure as needed.
    policies: {
    write : new Aerospike.WritePolicy({socketTimeout : 0, totalTimeout : 0}),
    operate : new Aerospike.OperatePolicy({socketTimeout : 0, totalTimeout : 0})
    }
    }
    Aerospike.connect(config).then(async (client) => {
    await client.put(key, { map: { nested: [32, 5, 85, 16, 22] } })
    const context = new Context().addMapKey('nested')
    const ops = [
    lists.get('map', -1)
    .withContext(context)
    ]
    const result = await client.operate(key, ops)
    console.log('Result:', result.bins.map) // => Result: 22
    client.close()
    })
MMNEPVFCICPMFPCPTTAAATR