I would like to know if I can “restart” the a sync session after user custom data has been updated.
Currently I’m getting a compensating write error because changes from user custom data wasn’t reflected on the sync session.
I have an example of my use case in the mongodb device sync permissions guide, which can be found in this link.
Considering the example above, a user custom data has the field “subscribedTo” which is an array of ids. This field is used in a permission role, it checks if the document field is inside the “subscribedTo” array.
Everything works as the guide shows, the problem appear when “subscribedTo” field is updated. At that point, I’m calling user.refreshCustomData() to get the newest addition, but even after that, if I try to insert a document, I get this compensating write error “Reporting compensating write for client version 3312 in server version 3635: Client attempted a write that is outside of permissions or query filters; it has been reverted”.
The guide says that when the “subscribedTo” field is updated, the changes don’t take affect until current session is closed and new session is started.
I’m wondering if I can restart the current session without closing my realm connection, since I would like to keep my sync subscriptions intact.