-2

I want to implement the soft delete feature in the project I am working on currently. The project is using feathersjs and mongoose. If anybody is having any idea how to implement it inside feathers hooks

Sibtain Wani
  • 89
  • 1
  • 9
  • Definition of soft-delete.
    An easy way to keep deleted data in your database. "Soft delete" in database lingo means that you set a flag on an existing table which indicates that a record has been deleted, instead of actually deleting the record.
    – Sibtain Wani Sep 25 '21 at 09:06

1 Answers1

1

we can use hooks collection created by feathers community feathers-hooks-common

use npm install feathers-hooks-common to import it in our library.

 import {softDelete} from 'feathers-hooks-common';

    export default {
      before: {
        all: [
//it takes an object as its parameter. in this case i passed an empty object
      softDelete({}),
    ],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
      }
    }

also add deleted field of type boolean in your schema

Sibtain Wani
  • 89
  • 1
  • 9