且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在所有的孩子中查询具有特定价值的财产

更新时间:2023-11-21 18:54:52

Firebase中的$ c> WHERE 子句。查看这个线程的一些很好的结构有关数据库风格查询的这个线程的提示,关于查询的这个博客,以及 docs

There are no WHERE clauses in Firebase. Check out this thread for some great structural tips on searching by multiple fields, this thread on database style queries, this blog on queries, and the docs.

你的第一个方法应该是分割数据如何被读回。如下所示:

Your first approach should be to segment data how it will be read back. Something like the following:

/todos/public
/todos/private
/todos/completed

您也可以利用优先级,如文档中所述。然后根据优先级获取项目。

You can also utilize priorities as explained in the docs. Then fetch items based on priority.

如果列表小于一千,这应该是数据正确分区,您可能只需抓取待办事项列表在客户端过滤它 - 这是一个很好的选择像这样的短集合,特别是使用像Angular这样的一个很好的绑定库。

If the list is less than a thousand, which it should be if data is properly partitioned, you can probably just grab the todo list and filter it at the client as well--a great option for short collections like this, particularly when working with a great binding lib like Angular.