I want to write a shopping-list app, where users will be able to give read-only or read-write permissions to other users.
I plan the database to look like this:
{
    "lists": {
        "1": {
            "title": "List #1",
            "items": [...],
            "owner": "user1",
            "read_only_access": [ {"user2": true} ],
            "read_write_access": [ {"user3": true} ],
        },
        "2": {
            "title": "List #1",
            "items": [...],
            "owner": "user1",
            "read_only_access": [ {"user3": true} ],
            "read_write_access": [],
        },
        "3": { ... }
    },
    "users": {
        "user1": {
            "name": "John",
        },
        "user2": { ... },
        "user3": { ... }
    }
}
How do I define the access rules for the "lists" tree, so that:
- The owner will have read-write access to all his lists
- Users in the read_only_access list will have read access
- Users in the read_write_access list will have read-write access
- Users who are neither the owner of the note, nor in the read_only_access and read_write_access lists of the note - won't have even read access to it
Thanks!
Slavik
 
     
    