| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
11年前发布

Apache Cassandra CQL3 二进制协议的 Node.js CQL 驱动:node-cassandra-cql

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);      }    }  );

项目主页:http://www.open-open.com/lib/view/home/1385018216875

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1385018216875.html
Apache Cassandra NoSQL数据库 node-cassandra-cql