【问题标题】:Fetch between values in Firebase database在 Firebase 数据库中的值之间获取
【发布时间】:2020-02-10 15:31:23
【问题描述】:

使用 react native,我想获取特定区域的位置。 在 Firebase 数据库中,我有“经度”字段和“纬度”字段。

我现在做的不行:

database()
   .ref()
   .child('places')
   .orderByChild('longitude')
   .startAt(min_longitude)
   .endAt(max_longitude)
   .then(fetchResp => {
      return fetchResp.json();
    })
   .then(fetchJsonResp => {
      resolve(fetchJsonResp);
   })

有什么想法吗?我做错了什么?

【问题讨论】:

标签: javascript firebase firebase-realtime-database latitude-longitude


【解决方案1】:

查询正确的是这个:

database()
   .ref()
   .child('places')
   .orderByChild('longitude')
   .startAt(min_longitude)
   .endAt(max_longitude)
   .once('value')
   .then(fetchResp => {
      return fetchResp.json();
    })
   .then(fetchJsonResp => {
      resolve(fetchJsonResp);
   })

.once('value') 不见了。

【讨论】:

  • 我首先解析数据库上的经度,然后从中过滤纬度中的元素。如果有办法直接将它提取到我想知道的数据库中。
猜你喜欢
  • 2020-08-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-03-26
  • 1970-01-01
  • 1970-01-01
  • 2016-12-04
  • 1970-01-01
相关资源
最近更新 更多