@rojo2/mongoose-status

1.0.1 • Public • Published

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)

Readme

Keywords

Package Sidebar

Install

npm i @rojo2/mongoose-status

Weekly Downloads

0

Version

1.0.1

License

MIT

Last publish

Collaborators

  • azazeln28
  • aitormm