【问题标题】:Firebase - get data from child x to child yFirebase - 从孩子 x 获取数据到孩子 y
【发布时间】:2015-09-15 08:03:13
【问题描述】:

我没有找到将数据从孩子 x 获取到孩子 y 的方法。

例如:

parent:
    child1: {...}
    child2: {...}
    child3: {...}
    child4: {...}

获取 child2 到 child3 之间的数据。

我知道我可以获取所有前三个孩子,然后删除第一个孩子。

但是如果我需要 child100 到 child 101 之间的数据呢?

这是用于检索数据的 firebase 文档:

https://www.firebase.com/docs/web/guide/retrieving-data.html

我在上面的文档中没有看到我需要的东西。

他通过获取所有数据并删除您不想要的数据来做到这一点:

Infinite scroll with AngularJs and Firebase

任何帮助表示赞赏!

【问题讨论】:

  • 为什么不使用startAt()endAt()?这些在您链接的文档页面上。
  • 我会试试...谢谢!
  • 听起来像是@AnidMonsur 的答案! :-)

标签: jquery firebase


【解决方案1】:

Firebase 支持多种不同的queries,包括startAt()endAt(),它们应该可以满足您的需求。

var parentRef = new Firebase("https://<YOUR-FIREBASE>/parent");

parentRef.orderByKey().startAt("child100").endAt("child101").on("child_added", function(snapshot) {
  // This will be called each time for child100, child101, and any nodes between them.
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-07
    • 1970-01-01
    • 1970-01-01
    • 2018-04-28
    • 1970-01-01
    相关资源
    最近更新 更多