javascript - Firebase timestamp filter -
i'm new firebase, i'm trying load data based on timestamp , retrieve between 2 timestamp using startat , endat. data pushed through python.
the data shown in sample screenshot
the data path popping-fire-7751.firebaseio.com/device488
activevolt: 396 avgpowerfactor: 0.95 avgthdi: 7.5 cubetemp: 37 datetime: "2016-02-08 15:16:32" timestamp: 1454924792 totalpowergen: 34
i'm pushing data through python setting priority timestamp. when try filter shown here returns null. without startat , endat shows values.
http://jsfiddle.net/casperkamal/ezutp/64/
var starttime = 1454924792; var endtime = 1454924798; new firebase("https://popping-fire-7751.firebaseio.com/") .startat(starttime) .endat(endtime) .once('value', show);
can me on i'm doing wrong ?
you're trying skip level in json tree:
var starttime = 1454924792; var endtime = 1454924798; new firebase("https://popping-fire-7751.firebaseio.com/") .child('device488') .startat(starttime) .endat(endtime) .once('value', show);
i highly recommend don't depend on implicit priority anymore , instead filter using orderbychild()
new firebase("https://popping-fire-7751.firebaseio.com/") .child('device488') .orderbychild('timestamp') .startat(starttime) .endat(endtime) .once('value', show);
you'll need add index security rules:
{ "rules": { "device488": { ".indexon": ["timestamp"] } } }
but more explicit behavior worth effort of adding this.
Comments
Post a Comment