How to use the aerospike.indexDataType function in aerospike

To help you get started, we’ve selected a few aerospike examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aerospike / aerospike-client-nodejs / examples / sindex.js View on Github external
async function sindexCreate (client, argv) {
  const options = {
    ns: argv.namespace,
    set: argv.set,
    bin: argv.bin,
    index: argv.index
  }

  let type = argv.type.toUpperCase()
  switch (type) {
    case 'NUMERIC':
      options.datatype = Aerospike.indexDataType.NUMERIC
      break
    case 'STRING':
      type = 'STRING'
      options.datatype = Aerospike.indexDataType.STRING
      break
    case 'GEO2DSPHERE':
      type = 'GEO2DSPHERE'
      options.datatype = Aerospike.indexDataType.GEO2DSPHERE
      break
    default:
      throw new Error(`Unsupported index type: ${argv.type}`)
  }

  await client.createIndex(options)
  console.info(`Creating ${type} index "${options.index}" on bin "${options.bin}"`)
}