Introducing mongoose-status-manager – status updates for mongoose models

For a project I’m currently working on, I needed to be able to update the status of a document.
For example, let’s assume it’s an Order.

I need to create it, then set it’s status to ‘Pending’
When the Payment is completed, I need to set it to ‘Paid’
Then, as the order progresses, I need to set it to ‘Packed’, finally ‘Dispatched’

I also need to keep a history of status updates, for audit / logging reasons.

So, I created Mongoose Status Manager

This makes it as easy as:

var order = new Order();

order.updateStatus('Pending');

//do some other stuff, then, later on:
order.updateStatus('Paid')'

It’s important to note that changes aren’t persisted until .save() is called.

Full documentation is available on the README on the github page

Available on github

Leave a Reply

Your email address will not be published. Required fields are marked *