我不确定为什么这行不通。我的表很简单(我什至暂时将所有内容都更改为 varchar),如果我使用 cqlsh,我可以插入。
var Connection = require('cassandra-client').Connection;
var db = new Connection({host: 'cassbx01.qualcomm.com', port: 9160, keyspace: 'foursq'});
db.execute("INSERT INTO checkins (fqid, name, address, city, state, zip, country, lat, lng, hereNow) values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
[value.id, value.name, value.location.address, value.location.city,
value.location.state, value.location.postalCode, value.location.country,
value.location.lat, value.location.lng, value.hereNow.count],
function (err) {
if (err || !saved) {
throw err;
}
});
运行时出现以下错误:
self.client.execute_cql_query(cql, ttypes.Compression.NONE, function(err,
^
TypeError: Cannot call method 'execute_cql_query' of null
at Connection.execute (/usr2/lsacco/nodejs/foursq-poc/node_modules/cassandra-client/lib/driver.js:407:17)
at exports.poller (/usr2/lsacco/nodejs/foursq-poc/controller/api.js:80:29)
at Array.forEach (native)
at Function._.each._.forEach (/usr2/lsacco/nodejs/foursq-poc/node_modules/underscore/underscore.js:76:11)
at IncomingMessage.exports.poller (/usr2/lsacco/nodejs/foursq-poc/controller/api.js:77:19)
at IncomingMessage.EventEmitter.emit (events.js:115:20)
at IncomingMessage._emitEnd (http.js:366:10)
at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23)
at CleartextStream.socketOnData [as ondata] (http.js:1366:20)
at CleartextStream.CryptoStream._push (tls.js:495:27)