Hello,
I am looking at setting up Mongo, Atlas, Realm Sync etc for an application where users can manage shopping lists. Each shopping list belongs to a household and each user can exist in 1 or more households.
Any user in a household can view/edit shopping lists within that household.
I have a schema that looks something like this:
Lists
{
"title": "list",
"properties": {
"_id": {
"bsonType": "string"
},
"household": {
"bsonType": "string"
},
"items": {
"bsonType": "array",
"categories": {
"bsonType": "array",
"items": {
"bsonType": "string"
}
}
},
"name": {
"bsonType": "string"
}
}
}
Households
{
"title": "household",
"properties": {
"_id": {
"bsonType": "string"
},
"name": {
"bsonType": "string"
}
}
}
Within each user’s custom data I want to store an array of household IDs that they are a member of.
How can I express this using flexible permissions?
I’ve come up with this:
{
"Lists": {
"roles": [
{
"name": "user",
"applyWhen": {},
"read": {
"household": {
"%in": "%%user.custom_data.households"
}
},
"write": {
"household": {
"%in": "%%user.custom_data.households"
}
}
}
]
}
}