You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Sometimes you have the id of an entity available and want to remove the relationships associated with them, or otherwise update in batch. There are times where some of the items which would match that query, are already loaded in the identify map. Today, the only way to blend the two, would be to run a query to get all of the entities, then update it your self, example:
constnewCard=newPaymentMethod();// some logic to populate and persist entityconstcustomer=awaitem.findOne(Customer,customerId,{populate: {paymentMethods: true}});for(constmethodofcustomer.paymentMethods){method.primary=false;}newCard.primary=true;
Describe the solution you'd like
Due to some of the advanced capabilities of the current QB implementation, it isn't practical to use that interface (eg: you can have a where clause on expr(), so we can provide a simpler API, which only supports an EntityData like object graph.
Interesting idea, we might wanna update the entity snapshots (originalEntityData) when assigning too, so we do not issue two update queries if there is a match.
I was actually thinking about having em.insert() too, that would basically partially flush the entities from parameter (cascading their relations, but not fully sure if it should handle more than inserts).
Yes, more like v6 I guess, I already have too many things in the pipeline for 5.x and for v6 I'd like to revisit the EM API a bit, introducing em.insert/update/delete that work similarly to the new em.upsert - works with entities as well as POJOs, at the same time respects the identity map (if things are already in context, it delegates writing to the flush call). Those would probably replace the native* methods.
Speaking of em.upsert(), your suggestion is quite aligned with what that method already does.
Is your feature request related to a problem? Please describe.
Sometimes you have the id of an entity available and want to remove the relationships associated with them, or otherwise update in batch. There are times where some of the items which would match that query, are already loaded in the identify map. Today, the only way to blend the two, would be to run a query to get all of the entities, then update it your self, example:
Describe the solution you'd like
Due to some of the advanced capabilities of the current QB implementation, it isn't practical to use that interface (eg: you can have a where clause on
expr()
, so we can provide a simpler API, which only supports anEntityData
like object graph.The above would effectively do two things:
em.assign()
)The text was updated successfully, but these errors were encountered: