A soft delete plugin for mongoose, inspired from Laravel Soft Delete
Using NPM npm install mongoose-soft-deleted
Using Yarn yarn add mongoose-soft-deleted
- Mongoose (CommonJS)
const mongoose = require('mongoose')
const softDelete = require('mongoose-soft-deleted')
mongoose.plugin(softDelete({ excludeDeleted: false }))
- Typegoose (Typescript)
import { Typegoose, plugin } from 'typegoose
import softDelete from 'mongoose-soft-deleted'
@plugin(softDelete())
class SomeModel extends Typegoose {}
excludeDeleted
for exclude deleted document, currently affected only on.find()
method. Defaulttrue
softDeleteOne(<condition>, <option>)
deleting one documentsoftDeleteMany(<condition>, <option>)
deleting manu documentrestoreOne(<condition>, <option>)
restore one deleted documentrestoreMany(<condition>, <option>)
restore many deleted document
Pull Request are welcome :)