Function set

  • Sets the list element at the specified index to a new value.

    Parameters

    • bin: string

      The name of the bin. The bin must contain a List value.

    • index: number

      Index of the element to be replaced.

    • value: AerospikeBinValue

      The new value to assigned to the list element.

    • Optionalpolicy: policy.ListPolicy

      Optional list policy.

    Returns ListOperation

    Operation that can be passed to the Client#operate command.

    @console.log

    const Aerospike = require('aerospike') const lists = Aerospike.lists const key = new Aerospike.Key('test', 'demo', 'mykey1') // INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE! var config = { hosts: '192.168.33.10:3000', // Timeouts disabled, latency varies with hardware selection. Configure as needed. policies: { read : new Aerospike.WritePolicy({socketTimeout : 0, totalTimeout: 0}), write : new Aerospike.ReadPolicy({socketTimeout : 0, totalTimeout: 0}), operate : new Aerospike.OperatePolicy({socketTimeout : 0, totalTimeout: 0})

    } } var ops = [ lists.set('tags', 1, 'green') ]

    Aerospike.client(config).connect((error, client) => { if (error) throw error client.put(key, { tags: ['blue', 'yellow', 'pink'] }, (error) => { if (error) throw error client.operate(key, ops, (error) => { if (error) throw error client.get(key, (error, record) => { if (error) throw error console.log(record.bins) // => { tags: [ 'blue', 'green', 'pink' ] } client.close() }) }) }) })

    This operation returns no result.

MMNEPVFCICPMFPCPTTAAATR