Add next("router") to exit from router
[express.git] / examples / view-locals / user.js
blob90ab1f389dfd7c0da9dfde6135aa8638e318c612
1 module.exports = User;
3 // faux model
5 function User(name, age, species) {
6 this.name = name;
7 this.age = age;
8 this.species = species;
11 User.all = function(fn){
12 // process.nextTick makes sure this function API
13 // behaves in an asynchronous manner, like if it
14 // was a real DB query to read all users.
15 process.nextTick(function(){
16 fn(null, users);
17 });
20 User.count = function(fn){
21 process.nextTick(function(){
22 fn(null, users.length);
23 });
26 // faux database
28 var users = [];
30 users.push(new User('Tobi', 2, 'ferret'));
31 users.push(new User('Loki', 1, 'ferret'));
32 users.push(new User('Jane', 6, 'ferret'));
33 users.push(new User('Luna', 1, 'cat'));
34 users.push(new User('Manny', 1, 'cat'));