Dear @objectbox how can I target one entity as a relation while using the putMany method in flutter...something like targeting one entity to many entities and put them once using the putMany #objectbox #flutter #flutterdev
Asked
Active
Viewed 206 times
1 Answers
0
If you want to target one entity by multiple source objects, use the ToOne
class to model your source entities. Then you can set the relation using ‘setTarget()’, individually for each of your sources.
This section of the docs has good examples: https://docs.objectbox.io/relations#to-one-relations
Finally you can put the source objects using this format*:
store.box< source_entity >().putMany([ source_entitiy_1, source_entity_2]);
*replace source_entity
with your own entities.
You can find detailed information about relations here: https://docs.objectbox.io/relations
putMany is described here: https://pub.dev/documentation/objectbox/latest/objectbox/Box-class.html#:~:text=putMany
Happy Coding!

Vahid Nesro
- 71
- 6
-
Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations, documentation, code sample to the answer itself, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – lepsch Jul 08 '22 at 05:55