mongoose-trashable

0.1.2 • Public • Published

mongoose-trashable

a mongoose plugin adding ablity to model instance to be trashed (soft deleted) / untrashed

adding following instance method to mongoose model:

  • trash() : mark an instance object as trashed
  • untrash() : recover a trashed object

Install

Install the module with:

npm install mongoose-trashable

Usage

var trashable = require('mongoose-trashable');
 
var TestSchema = new Schema({});
 
TestSchema.plugin(transable);
 
TestModel = mongoose.model("Test", TestSchema);
 
instance = new TestModel()
instance.trash(function(err, doc) {
    console.log("after trashed_at: doc.trashed_at:"+doc.trashed_at);
    doc.untrashed(function(err, doc){
      console.log("after untrashed: doc.trashed_at:"+doc.trashed_at);
    });
});
 

License

Copyright (c) 2014 yi Licensed under the MIT license.

Package Sidebar

Install

npm i mongoose-trashable

Weekly Downloads

1

Version

0.1.2

License

none

Last publish

Collaborators

  • yi