You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I have a basic model hierarchy built up of ToMany & ToOne relations:
Favourites with ToMany<Product>
Product with 3 different ToOne<ProductMetaData>
ProductMetaData no further relations
The Favourites object uses ObjectBox auto id, but the Product and ProductMetaData come from a remote database so I am manually assigning the Id property using:
objectbox: id = { "assignable": true }
According to this documentation you don't have to manually add the child objects, the tree will automatically be put:
You can persist whole trees of object relations at once: If the customer object does not yet exist in the database, the ToOne will put() it. If it already exists, the ToOne will only create the relation (but not put() it).
This doesn't appear to be happening with my structure because I am using manually assigned Ids (is this by design?). The tree does get populated if I use the auto id, but then I quickly end up with duplicate objects in the local store each time new data is fetched from the remote database. I can put a unique constraint on the database id & use ObjectBox auto id, but then I run into this long running issue.
Basic info:
ObjectBox version 1.4.1
Reproducibility: always
Device: iPhone X
OS: iOS 14.3
To Reproduce
Define an object structure similar to the one described above
Create a Favourites object and assign it a list of Product (none of which has been put into the store so far)
Yes, unfortunately it's not possible to have this convenience with self-assigned IDs. The workaround is to put the objects before using them in relation. The same limitation applies to Java, but we have some hint boxes in the docs there. We should do the same for Swift.
Describe the bug
I have a basic model hierarchy built up of ToMany & ToOne relations:
The Favourites object uses ObjectBox auto id, but the Product and ProductMetaData come from a remote database so I am manually assigning the Id property using:
objectbox: id = { "assignable": true }
According to this documentation you don't have to manually add the child objects, the tree will automatically be put:
You can persist whole trees of object relations at once: If the customer object does not yet exist in the database, the ToOne will put() it. If it already exists, the ToOne will only create the relation (but not put() it).
This doesn't appear to be happening with my structure because I am using manually assigned Ids (is this by design?). The tree does get populated if I use the auto id, but then I quickly end up with duplicate objects in the local store each time new data is fetched from the remote database. I can put a unique constraint on the database id & use ObjectBox auto id, but then I run into this long running issue.
Basic info:
To Reproduce
objectStore.box(for: Favourites.self).put(myFavouritesInstance)
Expected behavior
Based on the documentation I would expend the child tree to be auto populated.
The text was updated successfully, but these errors were encountered: