Hi there
I was under the impression that primary keys need only to be unique per realm, but with sync it seems that all primary keys need to be unique per atlas db. Can you let me know if that’s true or i’m doing something wrong?
we have some objects that are stored in a synced realm. These objects are partitioned per user id (as an owner kind of pattern) and have an _id that is a string, however not an UUID or alike. It’s a unique id that combines several things. They are definitely unique per realm however each user would be able to create same object for their partition and hence have the same _id as some other user’s objects.
We have some roundabout workarounds to make those _ids include the userid for global uniqueness but this adds some super weird code and prevents easy updates with realm.add(.., update: .modified)
So, is it true that objects in an Atlas collection that a realm maps to need unique primary keys for all objects regardless of their partition field?
for example:
class FollowedTag: Object {
@Persisted(primaryKey: true) var _id: String
@Persisted var _partition: String
}
User1: FollowedTag(_id: "tag_123", _partition: "user1ID")
User2: FollowedTag(_id: "tag_123", _partition: "user2ID")
should sync to a realm containing only first object for user 1 and only second object for user 2, however i can’t get this to work as both _id s are the same
Any solution?