Firebase嵌套查询时间戳范围

时间:2017-11-19 11:05:28

标签: javascript firebase timestamp

我遇到嵌套查询问题:

firebase.database().ref().child('panels').child('qa')
      .orderByChild('completed')
      .startAt(firstDay.getTime()) // January 1st, 2016
      .endAt(lastDay.getTime()) // current date (aug, 25th 2016)
      .once('value', function(snapshot) {
        $log.log(snapshot.numChildren());
      });

返回0

如果我在第一级节点中完成它可以工作:

firebase.database().ref().child('panels')
      .orderByChild('completed')
      .startAt(firstDay.getTime()) // January 1st, 2016
      .endAt(lastDay.getTime()) // current date (aug, 25th 2016)
      .once('value', function(snapshot) {
        $log.log(snapshot.numChildren());
      });

返回10;

嵌套解决方案无效的任何想法?

1 个答案:

答案 0 :(得分:0)

好的问题是:

   firebase.database().ref().child('panels')
    .orderByChild('qa/completed')
    .startAt(firstDay.getTime()) // January 1st, 2016
    .endAt(lastDay.getTime()) // current date (aug, 25th 2016)
    .once('value', function(snapshot) {
      $log.log(snapshot.numChildren());
    });

你必须orderByChild嵌套数据