objectbox-dart icon indicating copy to clipboard operation
objectbox-dart copied to clipboard

Add objects to ToMany by ID only

Open Paroca72 opened this issue 2 years ago • 3 comments

Hello,

It should be very useful to have inside ToMany class a method addId to add the entity reference directly by the id. Now have just add that force the programmer to insert a whole entity. But in many case what have are the ids and this force to load all the related entities before can add them as relations.

the ToOne already provide this function passing by targetId.

Thanks Sam

Paroca72 avatar Apr 25 '23 13:04 Paroca72

Thanks for the suggestion!

We could enable this by exposing InternalBoxAccess.relPut (directly or through a helper class). Changing ToMany itself does not seem a good idea as it is a list of objects.

A potential workaround: if the objects to be added all have an ID (e.g. the ID is not zero or null) it should be possible to just add objects with an ID set (and other values null or default) and save.

If others would like to have this feature, please thumbs up the first comment! This helps us track interest.

greenrobot-team avatar May 02 '23 08:05 greenrobot-team

Is this feature to be added?

m-moqbel avatar Aug 25 '24 06:08 m-moqbel

@m-moqbel This is currently not possible. You already added thumbs up to the first post, thank you! This helps us track interest.

greenrobot-team avatar Aug 26 '24 05:08 greenrobot-team