Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
lib
.gitignore
README.md
index.js
package-lock.json
package.json
tsconfig.json

README.md

Mongoose Soft Delete Plugin

A soft delete plugin for mongoose, inspired from Laravel Soft Delete

Installation

Using NPM npm install mongoose-soft-deleted Using Yarn yarn add mongoose-soft-deleted

Usage

  • 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 {}

Option

  • excludeDeleted for exclude deleted document, currently affected only on .find() method. Default true

Method

  • softDeleteOne(<condition>, <option>) deleting one document
  • softDeleteMany(<condition>, <option>) deleting manu document
  • restoreOne(<condition>, <option>) restore one deleted document
  • restoreMany(<condition>, <option>) restore many deleted document

Information

Pull Request are welcome :)

You can’t perform that action at this time.