我正在尝试使用以下代码使用nodejs cassandra-client 创建一个键空间-
var System = require('cassandra-client').System;
var sys = new System('127.0.0.1:9160');
sys.addKeyspace(ksDef, function(err) {
if (err) {
// there was a problem creating the keyspace.
} else {
// keyspace was successfully created.
}
});
Run Code Online (Sandbox Code Playgroud)
但我收到错误“ksDef 未定义”。请给我使用 cassandra-client 创建键空间的解决方案。什么是ksDef?如何定义ksDef?参考--url= https://github.com/racker/node-cassandra-client
谢谢苏布拉
它在 nodejs-driver github 存储库上的示例之一中进行了演示:
var cassandraDriver = require('cassandra-driver');
var client = new cassandraDriver.Client({
contactPoints: ['localhost:9042']
});
client.connect(function(e) {
var query;
query = "CREATE KEYSPACE IF NOT EXISTS examples WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3' }";
return client.execute(query, function(e, res) {
return console.log(e, res);
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3182 次 |
| 最近记录: |