Function create

  • Creates map create operation.

    Parameters

    • bin: string

      bin name.

    • Optionalorder: maps.order

      map order.

    • OptionalpersistIndex: boolean

      if true, persist map index. A map index improves lookup performance, but requires more storage. A map index can be created for a top-level ordered map only. Nested and unordered map indexes are not supported.

    • Optionalctx: Context

      optional path to nested map. If not defined, the top-level map is used.

    Returns any

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

    const Aerospike = require('aerospike')
    const maps = Aerospike.maps
    const key = new Aerospike.Key('test', 'demo', 'mapKey')

    // 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: {
    operate : new Aerospike.OperatePolicy({socketTimeout : 0, totalTimeout : 0})
    }
    }

    Aerospike.connect(config).then(async client => {
    let ops = [
    maps.create('map', maps.order.KEY_ORDERED, true)
    ]
    let result = await client.operate(key, ops)
    console.log(result.bins) // => { map: null }
    let record = await client.get(key)
    console.log(record.bins) // => { map: {} }

    await client.remove(key)
    client.close()
    })
MMNEPVFCICPMFPCPTTAAATR