【文件属性】:
文件名称:node-cassandra-cql.zip
文件大小:49KB
文件格式:ZIP
更新时间:2022-08-08 02:13:38
开源项目
node-cassandra-cql 是一个 Apache Cassandra CQL3 二进制协议的 Node.js CQL 驱动。CQL 是 Cassandra 的查询语言。该项目提供到多个主机的连接池、查询参数,以及可通过列名获取数值和支持 bigint。
示例代码:
// Creating a new connection pool to multiple hosts.
var cql = require('node-cassandra-cql');
var client = new cql.Client({hosts: ['host1:9042', 'host2:9042'], keyspace: 'keyspace1'});
// Reading
client.execute('SELECT key, email, last_name FROM user_profiles WHERE key=?', ['jbay'],
function(err, result) {
if (err) console.log('execute failed');
else console.log('got user profile with email ' result.rows[0].get('email'));
}
);
// Writing
client.execute('UPDATE user_profiles SET birth=? WHERE key=?', [new Date(1950, 5, 1), 'jbay'],
cql.types.consistencies.quorum,
function(err) {
if (err) console.log("failure");
else console.log("success");
}
);
// Streaming query rows
client.streamRows('SELECT event_time, temperature FROM temperature WHERE station_id=', ['abc'],
function(err, row) {
//the callback will be invoked per each row as soon as they are received
if (err) console.log("Oh dear...");
else {
console.log('temperature value', row.get('temperature'));
}
}
);
// Streaming field
client.streamField('SELECT key, photo FROM user_profiles WHERE key=', ['jbay'],
function(err, row, photoStream) {
//the callback will be invoked per each row as soon as they are received.
if (err) console.log("Shame...");
else {
//The stream is a Readable Stream2 object
stdout.pipe(photoStream);
}
}
);
【文件预览】:
node-cassandra-cql-master
----LICENSE.txt(1KB)
----lib()
--------encoder.js(10KB)
--------writers.js(10KB)
--------readers.js(8KB)
--------utils.js(3KB)
--------streams.js(13KB)
--------types.js(10KB)
--------connection.js(12KB)
----.npmignore(168B)
----.travis.yml(305B)
----test()
--------connectionTests.js(30KB)
--------config.js(411B)
--------testHelper.js(630B)
--------parserTests.js(6KB)
--------clientTests.js(25KB)
--------basicTests.js(12KB)
----README.md(14KB)
----.gitignore(135B)
----index.js(21KB)
----package.json(1KB)