Hi All,
I apologize if this is in the wrong category. I am relatively new to MongoDB and coding in general. The app (using node.js and Swift Realm Drivers) that my partner and I are working on requires the collaborator permissions ability that is listed under the Mongo Documentation → Device Sync Permissions Guide → Dynamic collaboration.
We have managed to implement it as described in the guide and it works when you have a single role with the $or function for the owner and collaborators, i.e.:
{
"$or": [
{
"userId": "%%user.id"
},
{
"invitedUserIds": "%%user.id"
}
]
}
However, what we found is that using this approach, you can only set the same permissions for collaborators and the owner, since they are under the same permissions set. When we try to create a second role with a separate set of permissions, i.e. one for owner and one for collaborator, and set them up such that one contains the owner read/write filter and the other contains the collaborator read/write filter, it doesn’t seem to grant access for collaborators.
Owner Role read/write filter:
{
"userId": "%%user.id"
}
Collaborator Role read/write filter:
{
"invitedUserIds": "%%user.id"
}
Is this because Atlas is setup to interpret arrays of collaborators with that $or function? Is there a way that we can set owner permissions and also provide an array of collaborators in a separate role with separate permissions from the owner of the document?
Thanks for any help in advance.