TechnologyJanuary 17, 2017

Promise Support in the DataStax Node.js Drivers

Jorge Bay Gondra
Jorge Bay Gondra
Promise Support in the DataStax Node.js Drivers
const query = 'SELECT name, email FROM users WHERE key = ?';
client.execute(query, [ 'someone' ], { prepare: true })
  .then(result => console.log('User with email %s', result.rows[0].email));
const result = await client.execute(query);
console.log('User with email %s', result.rows[0].email);
const tableMetadata = await client.metadata.getTable('ks1', 'table1');
const Promise = require('bluebird');
const client = new Client({
  contactPoints: [ 'host1', 'host2' ],
  promiseFactory: Promise.fromCallback
});
const client = new Client({
  contactPoints: [ 'host1', 'host2' ],
  policies: {
    timestampGeneration: new MyCustomTimestampGenerator()
  }
});
const result = await client.execute(query);
for (let row of result) {
  console.log(row.email);
}
Share

One-stop Data API for Production GenAI

Astra DB gives JavaScript developers a complete data API and out-of-the-box integrations that make it easier to build production RAG apps with high relevancy and low latency.