lookinlab / adonis-lucid-soft-deletes

Addon for soft deletes AdonisJS Lucid ORM
MIT License
93 stars 7 forks source link

Bulk delete doesn't work #9

Closed fuad-basyir closed 2 years ago

fuad-basyir commented 2 years ago

Hello, this case will delete row instead of setting deleted_at

await Categories
  .query()
  .whereIn('id', ids)
  .delete()
LookinGit commented 2 years ago

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

darshithedpara commented 11 months ago

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.

LookinGit commented 11 months ago

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