I searched through previous posts but couldn't find something that quite answered my question. Sorry if this has been covered before.
I'm trying to understand the best way to design my firebase in order to allow users to share and collaborate on sets of data. Let me use a ToDo type example (think Wunderlist) to explain what I'm trying to wrap my head around:
1. a user can authenticate and create a todo list
2. they can add and remove tasks from the list
3. they can add other users to those lists so they can all collaborate together
4. a user can see a list of users who are collaborators on the list
Here's how I would imagine I would set it up
1. create a users location with read/write permissions defined on the $user key so users can only see their own user object.
2. create a /lists location that will store all lists
3. include an array of owned list keys in the user object so the authenticated user can grab all the lists their a member of (because I don't want to add read permissions to the entire /lists location)
4. access to each $list key would be based on matching the user's ID to some sort of owner property on the list object (basically like an array of owners since there would be multiple?)
There are a couple issues that I'm having trouble getting around:
1. without true pk/fk style mapping between tables, how do I deal with a situation where user 1 and user 2 are both members of the same list and user 1 deletes the list? Would I need to handle the cleanup client side for all the other users?
2. is it even possible for me to define my read/write access based on whether an "array" contains the current user's ID? Would I need to basically stringify the owners array and use regex in my security config to handle read/write access?
3. This design just feels messy
I'm brand new to firebase so maybe I'm just totally missing some simple solution.