I am trying to build a structure that allows users to access only their own posts.
I have two possible ways in mind, and I'm not sure either of them is best practice. My end goal is to allow a user to read and write to all of their own posts only.
Approach A - Posts/Users (Not sure this can work from a security standpoint)
{
"posts" : {
"001" : {
"text" : "note 1",
"userID" : "user1"
},
"002" : {
"text" : "note 2",
"userID" : "user1"
},
"003" : {
"text" : "note 3",
"userID" : "user2"
}
}
}
Approach B - Users/Posts (Not as flat as Approach A)
{
"users" : {
"user1" : {
"posts" : {
"001" : {
"text" : "note 1",
},
"002" : {
"text" : "note 2",
},
}
},
"user2" : {
"posts" : {
"003" : {
"text" : "note 3",
},
},
}
}
I'm trying to follow the guidelines to keep data flat. In reality the post items will have more than just text, but not extend more than 2 levels deep. Thanks for any advice you can give!