"Cannot provide custom timestamp for conditional updates" 关于 datastax Node.js driver

"Cannot provide custom timestamp for conditional updates" on datastax Node.js driver

我正在尝试使用 datastax Node.js driver (cassandra-driver@2.2.2) 将记录插入 cassandra-2.2.3。大多数 cql 操作都运行良好,但是下面的 cql 语句无法正确执行。 driver 继续响应 "Cannot provide custom timestamp for conditional updates"?

var current = new Date();
var current_timestamp = current.getTime();
var userId = uuid.random();
var cqlStatement = "INSERT INTO user_credentials(email, password, userid) VALUES(?, ?, ?) IF NOT EXISTS USING TIMESTAMP ?";
var cqlParams = [user.emailAddress, user.password, userId, current_timestamp];

cassandra_client.execute(cqlStatment, cqlParams, { prepare: true }, function (err, result) {
        if (err) {
            var exception = new ttypes.UserManagementException() 
            exception.code = ttypes.UserManagementErrorCode.INTERNAL_ERROR;
            exception.reason = err.reason;
            callback(err); //tell client exception occurred
            return;
        }
        console.log("Execute correctly");}

有人遇到过类似的问题吗?或者有什么建议吗?

您应该在 query options:

中提供时间戳
const cassandra = require('cassandra-driver');
//Long value representing microseconds from the unix epoch
const timestamp = types.generateTimestamp();
client.execute(query, params, { prepare: true, timestamp: timestamp}, callback);

generateTimestamp() 接受 2 个可选参数(日期和微秒部分)。