We have a Role for a collection Place that depends on user custom data, so something similar to:
{
"roles": [
{
"name": "cityAccessRule",
"apply_when": {},
"document_filters": {
"write": {
"city": {
"$in": "%%user.custom_data.cities"
}
},
"read": {
"city": {
"$in": "%%user.custom_data.cities"
}
}
},
"read": true,
"write": true,
"insert": true,
"delete": true,
"search": true
}
]
}
We are updating the custom user data collection in a React Native app and calling refresh as doc:
realm.write(() => {
customUserData.cities = cities;
});
await user.refreshCustomData()
As soon as the user custom data is updated, we would expect to sync down the documents in the collection Place that passes successfully the role. But this is not the case, user needs to to kill the app and open again to trigger a new sync and see the expected Place documents.
All data seems correct on the server side (Dedicated M10) for the CustomUserData collection and UserSettings in AppSettings has correct configs for userId and Creation Function is working correctly. As well the connection between userId (CustomUserData collection) and the user.Id (User collection from Atlas) seems correct, as it is fetching correctly the expected documents, but only after the user restarts the app.
We performed some tests and issue seems to be connected with the user custom data update across the Mongo Atlas environment. Because if we use a static value for the Role comparison the sync is immediate as soon as the condition passes. But if it depends on a value from custom user data, then the sync it’s not immediate.
If there is any workaround would be appreciated, such as forcing the sync down on mobile side when we have the data updated.