0

我有两个 unix 时间戳,一个开始时间 (startDate) 和一个结束时间 (endDate)。使用下面的 moment 函数为我提供了一天的开始/结束:

search = {
  "end": { "$lte": moment(endDate).startOf('day').unix() },
  "start": {"$gte": moment(startDate).startOf('day').unix() }
};

然后我将搜索传递给我的 buildfire 函数:

buildfire.publicData.search(search ,'routes', (err, res) => {})

我的res是一个对象数组,每个对象都有一个data属性,其中包含startend属性:

res = [
  {
    data: {
      end: 1503554370297,
      start: 1503554368711
    }
  }
]

所有结果都返回,没有任何内容被过滤。

4

1 回答 1

1

这是文档数据存储搜索https://github.com/BuildFire/sdk/wiki/How-to-use-Datastore#buildfiredatastoresearchoptions-tag-optional-callback

我相信您没有正确发送过滤器。

您正在发送:

search = {
  "end": { "$lte": moment(endDate).startOf('day').unix() },
  "start": {"$gte": moment(startDate).startOf('day').unix() }
};
buildfire.publicData.search(search ,'routes', (err, res) => {})

它应该更像

var options = {
  "filter":{
        "$json.end": { "$lte": moment(endDate).startOf('day').unix() },
        "$json.start": {"$gte": moment(startDate).startOf('day').unix() }
  }
};
buildfire.publicData.search(search ,'routes', (err, res) => {})

基本上,因为您在对象filter中的属性它会返回所有内容optionsundefined

于 2017-08-24T21:03:58.633 回答