Reputation: 2245
I have been making an ionic app with Firebase but I have a general question.
if I have the database like this:
profile:
{
101:
{
name: jon
lastname: snow
...
reservations:
{
..lot of data
}
requests:
{
..lot of data
}
}
}
If I call from my app services :
firebase.database().ref('/profile/101/reservations).once('value') ...
does it download the whole profile data? because I am concerned about the data usage for the future. Also because I know that if I call only
firebase.database().ref('/profile/101').once('value') ...
It will download the whole data. I am just concerned if for the first case, it will be the same
Upvotes: 0
Views: 592
Reputation: 598817
When you attach a listener to a location (Reference
) (that you have permission to read) in the Firebase Database, it downloads all the data under that location.
When you attach a listener to a query (Query
) in a location (that you have permission to read), it downloads all data under the location that matches the query.
Upvotes: 3
Reputation: 1296
That's why you have to change your structure to :
profile:
{
101:
{
name: jon
lastname: snow
...
reservations: [801,...],
requests:[....]
}
},
reservations:{
801:{
profileId:101,
..lot of data
},
....
},
requests:{
.....
}
Upvotes: 1