【发布时间】:2015-12-26 00:52:20
【问题描述】:
我有以下几点:
var cassandra = require('cassandra-driver');
var clientCass = new cassandra.Client({
contactPoints: ['localhost'],
keyspace: 'localhost'
});
在代码的底部,我正在这样做:
//Now add a row or Check to see if the session already exists
var query = "INSERT INTO localhost.shirosessions (id,expired,last_access_ts,start_ts) \n\
VALUES ('" + theSession.sessionid + "',false,'"
+ component.getTimeStampA() + "','" + component.getTimeStampA() + "') IF NOT EXISTS";
//var params = [];
var consistency = client.cql.types.consistencies.quorum;
//client.executeAsPrepared(query, params, consistency, function (err) {
clientCass.execute(query, consistency, function (err) {
if (err)
console.log('Something when wrong and the row was not Inserted', err);
else {
console.log('Inserted on the cluster! Yay!');
}
});
但是,我得到的错误是:
TypeError: Cannot read property 'types' of undefined
我不明白? TYPES 在哪里定义?怎么样?
我是 Cassandra 的新手,但自 90 年代后期以来我一直在使用 MSSQL Server,并且对 SQL 有清晰的了解。
如果你能帮忙,谢谢。
另外,输入“IF EXISTS”是确保唯一记录的唯一方法吗?
【问题讨论】: