在我的数据库中,我有这样的时间戳值:
2015-06-25 11:39:17+0530
但在检索之后就像:
2015-06-25T06:19:13.362Z
....所以如何以正确的格式检索它。
表格结构:
CREATE TABLE test.tab (
key text,
time timestamp,
value decimal,
PRIMARY KEY (key, time)
) WITH CLUSTERING ORDER BY (time ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
AND comment = ''
AND compaction = {'min_threshold': '4', 'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32'}
AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99.0PERCENTILE';
CREATE INDEX key_index_tab ON test.tab (time);
和node.js代码用于检索:
var selectQuery='select * from tab where key=? and time>? and time<? allow filtering;';
Cclient.execute(selectQuery,[key,fromdate,partTodate],function(err, result) {
console.log(JSON.stringify(result.rows));
});
答案 0 :(得分:1)
Cassandra时间戳和Ecmascript Date都表示单个时刻(没有时区信息),因此存储和检索的日期相同,但您看到日期的字符串表示形式存在差异。
您可以使用Date methods以其他方式对其进行字符串表示或更改UTC偏移量。