node-cassandra-cql

码农软件 · 软件分类 · Node.js 扩展 · 2019-04-16 08:28:03

软件介绍

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

本文地址:https://codercto.com/soft/d/3686.html

在线

在线

王坚 / 中信出版集团股份有限公司 / 2016-9-1 / CNY 58.00

互联网成为基础设施,数据成为生产资料,计算成为公共服务。 移动互联网带来的真正影响,是人们的大部分时间都消耗在在线社会上了。 50多万年前的关键词是光明与黑暗,50多年前的关键词是数字和模拟,而今天的关键词是在线与离线。 移动互联网是比传统互联网在线程度更深的互联网。手机操作系统一旦做到了在线就会带来绝佳的用户体验。苹果手机不仅淘汰了传统手机,而且带来了一个新的时代。 对于......一起来看看 《在线》 这本书的介绍吧!

MD5 加密
MD5 加密

MD5 加密工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具