new IndexJob()
- Source:
- See:
Example
const Aerospike = require('aerospike') // INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE! var config = { hosts: '192.168.33.10:3000', policies: { write : new Aerospike.WritePolicy({socketTimeout : 0, totalTimeout : 0}) } } let binName = 'food' let indexName = 'foodIndex' let options = { ns: 'test', set: 'demo', bin: binName, index: indexName, datatype: Aerospike.indexDataType.STRING } Aerospike.connect(config) .then(client => { client.put(new Aerospike.Key('test', 'demo', 'mykey1'), {location: "Kale"}) .then((result) => { client.createIndex(options) .then(job => job.wait()) .then(() => { console.info('secondary index (SI) %s on %s was created successfully', indexName, binName) client.indexRemove('test', indexName) .then(() => { client.close() }) .catch(error => { console.error('Error removing index:', error) client.close() }) }) .catch(error => { console.error('Error creating index:', error) client.close() }) }) .catch(error => { console.error('Error writing record:', error) client.close() }) }) .catch(error => console.error('Error connecting to cluster:', error))
Extends
Methods
-
wait( [pollInterval] [, callback])
Wait until the job of creating a SI has completed.
-
Parameters:
Name Type Argument Default Description pollInterval
number <optional>
1000 Interval in milliseconds to use when polling the cluster nodes.
callback
doneCallback <optional>
The function to call when the operation completes.
- Overrides:
- Source:
Returns:
If no callback function is passed, the function returns a Promise that resolves once the job is completed.
- Type
- Promise