将时间戳记插入Cassandra

Lio*_*ana 5 cassandra node.js cassandra-node-driver

我创建了一个表,如下所示:

CREATE TABLE my_table (
  date text,
  id text,
  time timestamp,
  value text,
  PRIMARY KEY (id));

CREATE INDEX recordings_date_ci ON recordings (date);
Run Code Online (Sandbox Code Playgroud)

我可以使用以下Node代码简单地向表中添加新行:

const cassandra = require('cassandra-driver');
const client = new cassandra.Client({ contactPoints: ['localhost'], keyspace: 'my_keyspace'});

const query = 'INSERT INTO my_table (date, id, time, url) VALUES (?, ?, ?, ?)';
client.execute(query, ['20160901', '0000000000', '2016-09-01 00:00:00+0000', 'random url'], function(err, result) {
  if (err){
    console.log(err);
  }
  console.log('Insert row ended:' + result);
});
Run Code Online (Sandbox Code Playgroud)

但是,出现以下错误:

'错误:日期的预期长度为8或0个字节(24)

当我将时间戳更改为epoc时间时:

client.execute(query, ['20160901', '0000000000', 1472688000, 'random url']
Run Code Online (Sandbox Code Playgroud)

我得到:d

OverflowError:归一化的天数太大,无法容纳C int

我可以通过cqlsh插入新行,因此node.js驱动程序可能丢失了一些东西。

任何的想法?

谢谢

Pet*_*ons 6

如果您有字符串2016-09-01 00:00:00+0000,请改用new Date('2016-09-01 00:00:00+0000')