我正在努力构建一个结构,允许用户只访问他们自己的帖子。
我想到了两种可能的方法,但我不确定这两种方法都是最佳实践。我的最终目标是允许用户只对自己的帖子进行读写。
方法A-Posts/User(从安全角度不确定这是否可行)
{
"posts" : {
"001" : {
"text" : "note 1",
"userID" : "user1"
},
"002" : {
"text" : "note 2",
"userID" : "user1"
},
"003" : {
"text" : "note 3",
"userID" : "user2"
}
}
}方法B-用户/发布(不像方法A那样扁平)
{
"users" : {
"user1" : {
"posts" : {
"001" : {
"text" : "note 1",
},
"002" : {
"text" : "note 2",
},
}
},
"user2" : {
"posts" : {
"003" : {
"text" : "note 3",
},
},
}
}我正在努力遵循准则来保持数据的平顺性。在现实中,帖子项目将不仅仅是文本,但不会延伸到超过两个层次的深度。谢谢你能给我的建议!
发布于 2018-03-26 14:05:17
我会
{
"Users": {
"user1uniqueRef": {
"postIDUniqueRef1": {
"text" : "Here is someText"
"imageURL" : "https:// etc etc etc"
"postIDUniqueRef2": {
"text" : "Here is someText"
"imageURL" : "https:// etc etc etc"
"user2uniqueRef": {
"postIDUniqueRef1": {
"text" : "Here is someText"
"imageURL" : "https:// etc etc etc"
}
}
}https://stackoverflow.com/questions/44231473
复制相似问题