-
Notifications
You must be signed in to change notification settings - Fork 96
Closed
Description
Currently .remove method always uses findAndModify. It should use deleteOne if ctx.id is present.
Main problem right now it's not possible to remove document by _id without passing shard key, because .remove uses findAndModify, if it would use deleteOne you'll be able to remove document just by _id, without passing extra query with sharding key.
This is my current workaround, in before remove hook:
if (
ctx.id
&& ctx.service
&& ctx.service.Model
) {
await ctx.service.Model.deleteOne({ ...(ctx.params.query || {}), _id: ctx.id });
ctx.result = { _id: ctx.id };
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels