lookinlab/adonis-lucid-soft-deletes

Bulk delete doesn't work

Closed this issue · 3 comments

Hello, this case will delete row instead of setting deleted_at

await Categories
  .query()
  .whereIn('id', ids)
  .delete()

Hi, @fuad-basyir
Yep, you right. About it wrote in 'readme' into section ‘Applying Soft Deletes to a Model’.

Hello @LookinGit , he is saying that even after implementing ‘Applying Soft Deletes to a Model’.

import { compose } from '@ioc:Adonis/Core/Helpers' import { SoftDeletes } from '@ioc:Adonis/Addons/LucidSoftDeletes' export default class Categories extends compose(BaseModel, SoftDeletes) { }

When you try to delete multiple records at once, it is forced deleting all the records instead it should set the deleted_at field when we have implemented ‘Applying Soft Deletes to a Model’.

await Categories.query().whereIn('id', idsArray).delete()

Current behavior = Actual entries hard/force delete is happening
Expected behavior = Actual entries should be soft deleted.

Note : When we perform delete operation on single record it is working as expected

let record = await Categories.first()
await record.delete()

above code is soft deleting the record but when we try to mass delete then it performs hard delete.

Hi @darshithedpara
Re-read the section 'Applying Soft Deletes to a model' carefully with notes!