I would like some explanations about data retrieving in firebase. I'm not an expert in NoSql data structure and something is missing in my mind. It's not natural for me. However, I think i've understood the basics of Two-way relationships in this kind of structure.
Here is my data structure :
{
// Two-way relationships between accounts & logements
"accounts" : {
"uniqueId1" : {
"nom" : 'My name 1',
"email" : 'My email 1',
"logements" : {
uniqueIdLogement1 : true,
// do I have to list relationships with images & geofire here ?
uniqueIdLogement2 : true
},
"favorites" : {
uniqueIdLogement2 : true,
uniqueIdLogement25 : true,
uniqueIdLogement32 : true
}
},
....
},
// Each logement has his own "images" & "geofire" data
"logements" : {
"uniqueIdLogement1" : {
"nom_du_logement" : 'My logement name 1',
"accounts" : {
uniqueId1 : true
},
"images" : {
uniqueIdImages1 : true,
uniqueIdImages2 : true,
uniqueIdImages3 : true,
},
"geofire" : {
uniqueIdGeofire1 : true
},
},
...
},
"images" : {
"uniqueIdImages1" : {
"image" : 'My image URL 1',
"logements" : {
uniqueIdLogement1 : true
}
},
...
},
"geofire" : {
"uniqueIdGeofire1" : {
"g" : 'My geofire Data,
"l" : {
0 : '-44.34',
1 : '-3.2'
},
"logements" : {
uniqueIdLogement1 : true
}
},
...
}
}
I think everyone has his own point of view about data structure but in my opinion (in reference of Firebase Docs) it has to be quite like that. But if you see some updates, don't hesitate !
So, In angularJs, i would like to list each "logements" for account with "uniqueId1" for exemple and display their own "images" & geofire data (and check if they are my user's favorites logements).
Is it possible to do that ?
// list every logements for account ID1
// for each logement take images data & geofire data & check if favorites
// push infos in $scope.items & display with ng-repeat
Another question relative to that : When i remove a "logements" for User ID1, i want to remove also all images & geofire references ... ! Is it possible to do that too ?
// remove uniqueIdLogement1 from account ID 1
// remove images where "logements" = uniqueIdLogement1
// remove goofier where "logements" = uniqueIdLogement1
I think that if i understand that correctly, it will be okay for me ! I just can't see right now how it works and it's frustrating because i know there is a lot of potential with this kind of database. Can you explain me please some details about that . Thank you very much