co-aerospike

use aerospike with promise

Usage no npm install needed!

<script type="module">
  import coAerospike from 'https://cdn.skypack.dev/co-aerospike';
</script>

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