Skip to content

ardyfeb/mongoose-soft-deleted

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 :)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published