orm icon indicating copy to clipboard operation
orm copied to clipboard

Use Reference objects in HasMany and ManyToMany relations

Open roxblnfk opened this issue 3 years ago • 0 comments

Hello @roxblnfk does that mean that the only way to create a new record that has a ManyToMany to existing records is to load those existing records and assign them to the ManyToMany property? This would have a pretty severe scalability issue in some cases.

Can you think of a workaround, like exposing a OneToMany relationship to the join table and using references to it when saving/updating a record?

Our API allows a user to give an array of primary keys for many to many relationships, we then would ideally create reference objects for each of these IDs instead of loading them into memory just to create the relationship.

Thanks

Originally posted by @longshadowdev in https://github.com/cycle/orm/discussions/338#discussioncomment-3659342

roxblnfk avatar Sep 18 '22 09:09 roxblnfk