How to query firebase for property with specific value inside all children

后端 未结 3 1486
抹茶落季
抹茶落季 2020-11-29 23:11

I have this data structure, where todos are organized to follow path /todos/uid/

{
  \"metausers\" : {
    \"simplelogin:1\" : {
      \"displayName\" : \"Jo         


        
3条回答
  •  不知归路
    2020-11-29 23:41

    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.

    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.

提交回复
热议问题