1.0.1 • Published 6 years ago

@rojo2/mongoose-status v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Mongoose Status plugin

Travis CI

This plugin has a very simple interface:

const User = new mongoose.Schema({

});

User.plugin(status, {
  default: "not-enabled",
  enum: ["not-enabled", "enabled", "disabled"],
  transitions: {
    "not-enabled": ["enabled"],
    "enabled": ["disabled"],
    "disabled": ["enabled"]
  }
});

// And then when you need to transition from an state A
// to a state B, you should do:
const result = user.transitionTo("disabled");
if (!result) {
  // The transition couldn't be done
}
// The transition went well

Made with ❤ by ROJO 2 (http://rojo2.com)