I want to implement the following constraints:
- Users can save movies (titles) and view the title uploaded by other users too.
- All users must be able to access all of the movies, but must only be able to edit/add/delete their own.
- Users should not be able to view in any way who added a movie, only if that person is them. (I would like to make it so they can't even view if "X" and "Y" movie are from the same user)
- User can have up to 3 movies added (this number is the client's requested one, but what if they change their mind, how to make it scalable?)
I have users logging in with firebase authentication, thus getting a user uid. I would like to make most constraints/checks on firestore server side, wherever possible, using firestore rules, on whatever other technology I don't know of as of writing this question.
I have thought of the following structures:
movies: {
userUid1: {
movie1:{
name: "dummy name 1"
},
movie2:{
name: "dummy name 2"
}
},
userUid2: {
movie1:{
name: "first dummy name"
},
movie2:{
name: "second dummy name"
},
movie3:{
name: "third dummy name"
}
}
}
or:
movies: {
movieUid1: {
name: "dummy name 1",
userId: "userUid1"
},
movieUid2: {
name: "dummy name 2",
userId: "userUid1"
},
movieUid3: {
name: "dummy name 3",
userId: "userUid2"
},
movieUid4: {
name: "dummy name 4",
userId: "userUid2"
},
movieUid5: {
name: "dummy name 5",
userId: "userUid2"
}
}
This project is only for some friends, so nothing serious, but still I would like to structure the best way possible. I don't think this is relevant, but I use flutter to create the app.