For my iOS app I’ve created custom user data collection for my users. I want to ensure that some of the fields in that collection are unique - like username. My first idea was to call a Realm Function which would first call another function as system user to check if username is taken and if not then write username to custom user data of user that called that function (users can only read and write on partition matching their generated user id).
The issue with this solution is that I assume that 2 users could call this function at the same time and it could pass for both of them. Maybe something like unique indexes could help? Is there a way to add unique index on Realm Object fields? Or maybe is there some other solution for ensuring uniqueness in MongoDB Realm?