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.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.2
    32
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.2
    32
  • 0.1.1
    2
  • 0.1.0
    2

Package Sidebar

Install

npm i mongoose-trashable

Weekly Downloads

4

Version

0.1.2

License

none

Last publish

Collaborators

  • yi