【问题标题】:Is there a way to pull only the entries in a specific range in firebase?有没有办法只提取firebase中特定范围内的条目?
【发布时间】:2018-08-29 19:07:06
【问题描述】:

我有一个数据库,其中已经包含大量数据,我们需要能够根据添加日期提取条目。有没有办法只提取在 2018 年 1 月 1 日和 2018 年 1 月 7 日之间添加的条目?

【问题讨论】:

  • 你能提供一些关于你的数据结构的信息吗?

标签: firebase firebase-realtime-database


【解决方案1】:

是的,您可以使用此查询:

DatabaseReference ref=FirebaseDatabase.getInstance().getReference().child("times");
ref.orderByChild("date").startAt("2018-01-01").endAt("2018-01-07");

如果你有这个例子:

times
  pushid
   date:2018-01-01
  pushid
   date: 2018-01-07

【讨论】:

  • 这确实有效,但我们的查询仍然运行得很慢。有没有办法加快查询本身?或者更快地对数据进行排序?
  • 也许可以进一步优化数据库stackoverflow.com/questions/39768084/…,或者在提供更多信息的情况下提出问题
猜你喜欢
  • 2021-06-07
  • 2019-12-14
  • 2017-08-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-04-17
  • 1970-01-01
相关资源
最近更新 更多