Skip to content

Instantly share code, notes, and snippets.

@artcommacode
Last active December 14, 2015 02:39
Show Gist options
  • Save artcommacode/5014995 to your computer and use it in GitHub Desktop.
Save artcommacode/5014995 to your computer and use it in GitHub Desktop.
// USER MODEL
var User = function (user) {
this.user = user;
};
User.prototype.all = function (callback) {
var User = this;
var users = [];
/* snip */
callback(error, user);
};
User.prototype.save = function (callback) {
var User = this
, user = User.user;
/* snip */
callback(error, users);
};
User.prototype.get = function(user, callback) {
var User = this;
if (!user.id) user = {id: user};
/* snip */
User.user = user;
callback(error, user);
};
module.exports = User;
// USER CONTROLLER
var User = require('models/users');
exports.index = function(req, res, next) {
var user = new User();
user.all(function (error, users));
};
exports.create = function(req, res, next) {
var user = new User(req.body.user);
user.save(function (error, user));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment