Hello everybody !
I’m working on an iOS app with Realm and I’m having some difficulties to work with the RealmSwift.List type. I’m trying to implement the “To-Many Relationship” described here: https://realm.io/docs/swift/0.102.0/
I have 2 different collections “Items” & “QuoteInformation” in 2 different databases. In “QuoteInformation” I want to have a var (called “quoteItems”) which is a list of “Items”.
Here is how I defined the quoteItems var in the QuoteInformation schema:
"quoteItems": {
"bsonType": "array",
"items": {
"bsonType": "objectId"
}
}
And I added the following dependency between quoteItems and the “_id” property of Items:
{
"quoteItems": {
"foreign_key": "_id",
"ref": "#/relationship/mongodb-atlas/Libraries/Items",
"is_list": true
}
}
In my iOS app, I append some Items in my quoteItems list but when I try to upload the quoteItems with realm.add() I got the following error:
"Attempting to create an object of type ‘Items’ with an existing primary key value ‘5f0a27e2bf392975530711d3’ "
I don’t understand why Realm is thinking that i’m adding a new Items while i’m just trying to save it in a list.
Thanks for you help !