Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add objects to ToMany by ID only #532

Open
Paroca72 opened this issue Apr 25, 2023 · 3 comments
Open

Add objects to ToMany by ID only #532

Paroca72 opened this issue Apr 25, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@Paroca72
Copy link

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 Paroca72 added the enhancement New feature or request label Apr 25, 2023
@greenrobot-team greenrobot-team changed the title ToMany addId Add objects to ToMany by ID only May 2, 2023
@greenrobot-team
Copy link
Member

greenrobot-team commented May 2, 2023

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.

@m-moqbel

This comment was marked as duplicate.

@greenrobot-team

This comment was marked as duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants