【发布时间】:2016-12-05 13:44:14
【问题描述】:
我想了解有关在 Firebase 中检索数据的一些说明。我不是 NoSql 数据结构方面的专家,我的脑海中缺少一些东西。这对我来说不自然。但是,我想我已经了解了这种结构中双向关系的基础知识。
这是我的数据结构:
{
// 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
}
},
...
}
}
我认为每个人对数据结构都有自己的观点,但在我看来(参考 Firebase 文档)它必须是这样的。但是,如果您看到一些更新,请不要犹豫!
因此,在 angularJs 中,我想列出具有“uniqueId1”的帐户的每个“logements”,并显示他们自己的“图像”和 geofire 数据(并检查它们是否是我的用户最喜欢的 logements)。
有可能吗?
// 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
与此相关的另一个问题:当我删除用户 ID1 的“登录”时,我还想删除所有图像和 geofire 引用...!是否也可以这样做?
// remove uniqueIdLogement1 from account ID 1
// remove images where "logements" = uniqueIdLogement1
// remove goofier where "logements" = uniqueIdLogement1
我认为,如果我理解正确,那对我来说没问题!我现在无法看到它是如何工作的,这令人沮丧,因为我知道这种数据库有很大的潜力。你能给我解释一下吗?非常感谢
【问题讨论】:
标签: javascript firebase firebase-realtime-database