user.js
This file
Path
examples/view-locals/user.js
31 lines · 570 bytes · JavaScript
Last changed by
Not known.
History of this fileTake it
1234567891011121314151617181920212223242526272829303132module.exports = User;
// faux model
function User(name, age, species) { this.name = name; this.age = age; this.species = species;}
User.all = function(fn){ process.nextTick(function(){ fn(null, users); });};
User.count = function(fn){ process.nextTick(function(){ fn(null, users.length); });};
// faux database
var users = [];
users.push(new User('Tobi', 2, 'ferret'));users.push(new User('Loki', 1, 'ferret'));users.push(new User('Jane', 6, 'ferret'));users.push(new User('Luna', 1, 'cat'));users.push(new User('Manny', 1, 'cat'));