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
For most DB adapters, we have to do an initial lookup before doing the actual patch/update database method. For more context see this issue: #3363.
But, we could skip this initial lookup under certain (very common) conditions. For both patch and update, if the id is present but query is not present, then we can skip the originalId lookup. This covers the most basic, common use cases I believe.
// These methods could skip the `originalId` lookupconstresult=awaitservice.patch(1,data);constresult=awaitservice.update(1,data);// These methods must use the `originalId` lookupconstparams={query: { ... }};constresult=awaitservice.patch(1,data,params);constresult=awaitservice.patch(null,data,params);constresult=awaitservice.update(1,data,params);
This would result in the most common mutation methods going from 3 DB operations to 2 DB operations! While this update would add a bit more code, I think it is worth it for the performance gain. And, it would better explain why these adapters use the originalId lookup, ultimately lowering the overall "complexity" of the code because it is more obvious why/when the originalId lookup is necessary.
The text was updated successfully, but these errors were encountered:
In Mongo, there are other upgrades like using findOneAndReplace instead of replaceOne and findOneAndUpdate instead of updateOne, both of which have an option to return the updated document alleviating the need for the second lookup.
For most DB adapters, we have to do an initial lookup before doing the actual patch/update database method. For more context see this issue: #3363.
But, we could skip this initial lookup under certain (very common) conditions. For both patch and update, if the id is present but query is not present, then we can skip the originalId lookup. This covers the most basic, common use cases I believe.
This would result in the most common mutation methods going from 3 DB operations to 2 DB operations! While this update would add a bit more code, I think it is worth it for the performance gain. And, it would better explain why these adapters use the originalId lookup, ultimately lowering the overall "complexity" of the code because it is more obvious why/when the originalId lookup is necessary.
The text was updated successfully, but these errors were encountered: