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

Is there any easier option to update an object in a "one-to-many" relationship? #36

Closed
vicenrico opened this issue Oct 1, 2022 · 1 comment

Comments

@vicenrico
Copy link

vicenrico commented Oct 1, 2022

Hello, how can I easily update an object belonging to a one-to-many relationship?. I mean:


Table Movies(id, title, ...)
Table Genres(id, movie_id, name)

I have, movie Blade runner and a list of genres( scifi, action...). What I'm doing is delete the genres and again insert the new ones, but I remember years ago I was using ormlite and they had something like 'movie.getGenres.update(...)'
Is there something similiar to this for persism? Am I using the best and most efficient way to update a register in a one-to-many relationship? There will be an easier feature to update 'children' records in this kind of relationships?

By the way, I'm using sqlite as DB Engine

@vicenrico vicenrico changed the title Is there any easy option to update an object in a "one-to-many" relationship? Is there any easier option to update an object in a "one-to-many" relationship? Oct 1, 2022
@sproket
Copy link
Owner

sproket commented Oct 2, 2022

I don't have anything specific for that. Usually I take the data from the DB and compare to the data being submitted to decide what to insert/update or delete. Maybe if I think of a generalized way to do this I can add it as a feature. Thanks!

@sproket sproket closed this as completed Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants