How can I get data from only one table in Firebase Realtime Database

Viewed 35

I have a big problem that I need to address quickly. I have my firebase realtime database structured this way:

Picture:

enter image description here

My question is simple: How can I only retrieve the friendIds as a list without the inner data i.e firendsStatus, lastMessage, lastTimestamp...

My current response is like this: {friendsArray: {'34uibjerktbbt854uigefg' : {'lastMessage' : 'ajskdkjasd',...}, {'574uibsd784546ktbbt854uigefg' : {'lastMessage' : 'weurhisdf', ...} and so on}}

I want it to be like this: {friendsArray: ['34uibjerktbbt854uigefg', '34uibjerktbbt854uigefg', '34uibjerktbbt854uigefg', and so on]}

Is there any way to achieve this because if I observe the whole data it gets pretty big and slow?

Thank You

1 Answers

Thats unfortunately not how realtime database works it always fetches all of the data below as well, you can use cloud firestore instead or re-design your realtime database so the nodes are not tested you can create separate nodes that only contains the data you need to fetch

Related