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 there a way to use the softDelete hook for batch requests?
I found out deleting multiple records at once via batch remove does nothing, the workaround is simply making multiple (individual) remove calls.
Steps to reproduce
// DOES NOT WORK: batch/multi-remove by softDelete()app.service('files').remove(null,params)// WORKS: less-performant workaroundconstfiles=awaitapp.service('files').find({
...params,paginate: false})awaitPromise.all(files.map(({ _id )=>app.service('files').remove(_id)))
The softDelete hook is configured as follows:
softDelete({// returns query object to spread in querydeletedQuery: async(ctx: HookContext)=>{constparam=ctx.params.query?.deletedAtconstisTruthy=['true',true].includes(param)return{deletedAt: truthy ? {$ne: null} : null}},// returns patch data to spread in data for removeremoveData: async(ctx: HookContext)=>({deletedAt: newDate().toISOString()})})
Expected behavior
Files should be set to new Date().toISOString() when deleting one, or multiple in batch.
Actual behavior
Only files deleted individually are set to new Date().toISOString().
The text was updated successfully, but these errors were encountered:
Is there a way to use the
softDelete
hook for batch requests?I found out deleting multiple records at once via batch remove does nothing, the workaround is simply making multiple (individual) remove calls.
Steps to reproduce
The
softDelete
hook is configured as follows:Expected behavior
Files should be set to
new Date().toISOString()
when deleting one, or multiple in batch.Actual behavior
Only files deleted individually are set to
new Date().toISOString()
.The text was updated successfully, but these errors were encountered: