Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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}"`)
}