angularjs - Firebase simple query date range ... doesn't work -
i have array keys :
['-ksh1rj8bgbowkdwdn0j', '-ksh0b8mfpcb2_zi8h3q', ...];
and each key, know if "ts_exp" expiration timestamp between yesterday , tomorrow both timestamps.
var yesterday = moment().subtract(1, 'day').format("x"); var tomorrow = moment().add(1, 'day').format("x"); foreach(... key){ var rootref = firebase.database().ref('demandes').child(key) .orderbychild('ts_exp') .startat(yesterday) .endat(tomorrow); rootref.once("value", function(messagesnapshot) { console.log(messagesnapshot.val()); // return null }); }
what's wrong query? this null (but have "demande" have "ts_exp" between 2 values). did .indexon "ts_exp" in firebase rules also.
thank
data structure :
-demandes ----- -ksh1rj8bgbowkdwdn0j ---------- ts_exp : 14123123123, ---------- title : "pipo1", ---------- desc : "desc" ----- -ksh0b8mfpcb2_zi8h3q ---------- ts_exp : 14123176576, ---------- title : "pipo2", ---------- desc : "desc2"
looks ts_exp values numbers (14123123123) startat / endat strings, , firebase database sorts numbers before strings, query searching range no data.
untested, try:
var yesterday = moment().subtract(1, 'day').valueof(); var tomorrow = moment().add(1, 'day').valueof();
Comments
Post a Comment