Hi All,
I am following this tutorial but I’m running into a InvalidParameter Error when querying my Atlas database.
My sync permissions are configured as follows:
{
"rules": {
"SessionObj": [
{
"name": "SessionObjSubsc",
"applyWhen": {},
"write": {
"$or": [
{
"owner": "%%user.id"
},
{
"collaborators": "%%user.id"
}
]
}
}
]
}
}
I am querying my atlas database from within my app as follows:
dbCollection.aggregate(pipeline: generalPipeline) { result in
//handle result here
}
In my app services logs I am getting the following InvalidParameter Error:
“cannot use ‘owner’ in expression; only %% like expansions and top-level operators may be used as top-level fields.”
If I simply set read and/or write to true and make the query, I don’t see any error and successfully retrieve documents, similarly if I just set write to. {“owner”: “%%user.id”}. This leads me to believe it is something to do with the “$or” operator.
Has anyone been able to successfully set permissions with $or when using an aggregation pipeline?
Does anyone know how I may be able to fix/avoid the error I am seeing?
Thanks,
Ben