Fetch particular fields from Firebase database

后端 未结 1 1249
孤独总比滥情好
孤独总比滥情好 2020-12-11 17:45

I am working on firebase project, where i stored user info within a Table. Now my requirement is to show all user\'s in a Table. Here is my database snapshot

相关标签:
1条回答
  • 2020-12-11 18:23

    When you read a node, you'll have to retrieve its entire content. So, there is no way to fetch only specific fields from the data returned on reading a path.

    Having said that, if it's possible for your use case, I would suggest you to denormalise data with the purpose of queries that only retrieve the information that you need.

    For doing that, you can have a separate node that can be called something like Users-NameandEmailList. Now, in this table, have user uids as your child keys, and each entry shall have only a an email and name field.

    Something like this :-

    Users-NameandEmailList :{
    
           user1key :{
                 name : "ABC"
                 email : "abc@abc.com"
                     },
           user2key : {..},
    
                            }
    

    I agree that this could lead to replication of data, but if you want to minimise download redundancy and optimise for speed, then this is the way to go!

    0 讨论(0)
提交回复
热议问题