co-aerospike
v0.1.0
Published
use aerospike with promise
Downloads
3
Readme
co-aerospike
Usage
const Aerospike = require('aerospike');
const coAerospike = require('co-aerospike');
const client = Aerospike.connect({
hosts: 'aerospike-dev.s.qima-inc.com'
});
coAerospike.client(client);
let key = new Key('test', 'co-aerospike', '1');
client.put(key, {a: 1})
.then(()=>{
return client.get(key)
})
.then((res)=>{
console.log(res.a);
})
.then(()=>{
client.put(key, {b: 1}, function(err) {
if (err) throw err;
}); //compatible with callback,but will not return promise
})
Set promise
const coAerospike = require('co-aerospike');
const Promise = require('bluebird');
coAerospike.Promise = Promise;
// client.get(key) instanceof Promise;
Sync function
Some method of client is sync, doesn't need callback ['LargeList', 'close', 'info', 'isConnected', 'query', 'scan', 'sendError', 'updateLogging'] Those method will not be promisify