对于我的Firebase数据结构,我希望它能够处理以下内容:
用户可以创建一种记录思想的方法。他们想叫什么就叫什么。Mary Chen传递参数journal,而Mr Owner希望将其命名为(pass参数) log。Firebase将它们保存为自己的树,并将其命名为用户要求命名的任何参数。
然后出现另一棵树:whenLoggedIn + \(parameter)。此树将yyyy-mm-dd日期保存到相应的post。
示例:
{
"uids": {
"D0Ez8edYhIbTuUfmIeO0KOq5xVB3": {
"friends": {
"IbTuUfmIeO0KOBr5Q4gAqD": true
},
"name": "Mary Chen",
"journal": {
"entry 1- trader joes": "went to store! :)",
"entry 2- ate sushi": "took out the garbage today then got free sushi from trader joes!!!"
},
"whenLoggedInJournal": {
"1": "1997-12-25",
"2": "2016-2-23"
}
},
"L8kBHaGBr5Q4gAqDOhFY29Okepm1": {
"friends": {
"D0Ez8edYhIbTuUfmIeO0KOq5xVB3": true
},
"name": "Mr Owner",
"journal": {
"log 1": "spotted some drunkard in my store",
"log 2": "drainage pipe clogged with tomatos, I suspect the drunkard",
"log 3": "did inventory check, 1 less sushi box, suspect the drunkard"
},
"whenLoggedInLog": {
"1": "1997-12-25",
"2": "2016-2-27",
"3": "2016-4-2"
}
}
}
}我在Firebase指南上阅读了“结构化数据”,但我没有掌握如何一次添加树。我还想实现一个扁平的数据集,这对我所做的工作是否必要?
发布于 2016-06-26 04:28:15
推荐的Firebase数据结构是将每个实体拉到它自己的顶级节点。因此,就你的情况而言,这将导致:
{
"userNames": {
"D0Ez8edYhIbTuUfmIeO0KOq5xVB3": "Mary Chen",
"L8kBHaGBr5Q4gAqDOhFY29Okepm1": "Mr Owner"
},
"userFriends": {
"D0Ez8edYhIbTuUfmIeO0KOq5xVB3": {
"IbTuUfmIeO0KOBr5Q4gAqD": true
},
"L8kBHaGBr5Q4gAqDOhFY29Okepm1": {
"D0Ez8edYhIbTuUfmIeO0KOq5xVB3": true
}
},
"userJournals": {
"D0Ez8edYhIbTuUfmIeO0KOq5xVB3": {
"entry 1- trader joes": "went to store! :)",
"entry 2- ate sushi": "took out the garbage today then got free sushi from trader joes!!!"
},
"L8kBHaGBr5Q4gAqDOhFY29Okepm1": {
"log 1": "spotted some drunkard in my store",
"log 2": "drainage pipe clogged with tomatos, I suspect the drunkard",
"log 3": "did inventory check, 1 less sushi box, suspect the drunkard"
}
},
"whenLoggedInJournals": {
"D0Ez8edYhIbTuUfmIeO0KOq5xVB3": {
"1": "1997-12-25",
"2": "2016-2-23"
},
"L8kBHaGBr5Q4gAqDOhFY29Okepm1": {
"1": "1997-12-25",
"2": "2016-2-27",
"3": "2016-4-2"
}
}
}这一结构:
https://stackoverflow.com/questions/38034952
复制相似问题