retrieve timestamp value properly from cassandra in node.js -
in database have timestamp value this:
2015-06-25 11:39:17+0530
but after retrieving it's like:
2015-06-25t06:19:13.362z
....so how retrieve in correct format.
table structure:
create table test.tab ( key text, time timestamp, value decimal, primary key (key, time) ) clustering order (time asc) , bloom_filter_fp_chance = 0.01 , caching = '{"keys":"all", "rows_per_partition":"none"}' , comment = '' , compaction = {'min_threshold': '4', 'class': 'org.apache.cassandra.db.compaction.sizetieredcompactionstrategy', 'max_threshold': '32'} , compression = {'sstable_compression': 'org.apache.cassandra.io.compress.lz4compressor'} , dclocal_read_repair_chance = 0.1 , default_time_to_live = 0 , gc_grace_seconds = 864000 , max_index_interval = 2048 , memtable_flush_period_in_ms = 0 , min_index_interval = 128 , read_repair_chance = 0.0 , speculative_retry = '99.0percentile'; create index key_index_tab on test.tab (time);
and node.js code retrieval:
var selectquery='select * tab key=? , time>? , time<? allow filtering;'; cclient.execute(selectquery,[key,fromdate,parttodate],function(err, result) { console.log(json.stringify(result.rows)); });
both cassandra timestamp , ecmascript date represent single moment in time (without timezone information), date stored , retrieved same seeing differences in string representation of date.
you can use date methods string represent in way or change utc offset.
Comments
Post a Comment