datastax Node.js驱动程序中的“无法为条件更新提供自定义时间戳”

我尝试使用datastax Node.js驱动程序(cassandra-driver@2.2.2)将logging插入到cassandra-2.2.3中。 大部分的cql操作都能正常工作,但是下面的cql语句不能正确执行。 驱动程序继续响应“无法提供有条件更新的自定义时间戳”?

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

任何人遇到类似的问题? 或者有什么build议?

您应该在查询选项中提供时间戳:

 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个可选参数(date和微秒部分)。