simple-mongoose-controller
v0.1.1
Published
A simple controller for mongoose models
Readme
README
This module provides a very simple controller for mongoose models.
How to use
#!Node.js
var Controller = require('simple-mongoose-controller');
var model = // some Mongoose Model
var controller = new Controller(model);
// Get all documents of this model:
controller.getAll(callback);
// Get a document by its id:
controller.getById(id, done);
// Create a new document:
controller.create(data, done);
// Update existing document:
controller.update(id, data, done);
// Delete a document:
controller.delete(id, done);done is a callback function that uses the error first pattern. Also the controller methods return promises that you can use instead of the callback methods.
