Skip to content
Myr

user.js

This file

Path

examples/view-locals/user.js

36 lines · 730 bytes · JavaScript

Last changed by

Not known.

History of this file

Take it

The walk stopped after 200 commits: lines older than 2027b87 point at it.

fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87

lines 1–36why, one step back
1'use strict'
23module.exports = User;45// faux model67function User(name, age, species) {8 this.name = name;9 this.age = age;10 this.species = species;11}1213User.all = function(fn){14 // process.nextTick makes sure this function API15 // behaves in an asynchronous manner, like if it16 // was a real DB query to read all users.17 process.nextTick(function(){18 fn(null, users);19 });20};2122User.count = function(fn){23 process.nextTick(function(){24 fn(null, users.length);25 });26};2728// faux database2930var users = [];3132users.push(new User('Tobi', 2, 'ferret'));33users.push(new User('Loki', 1, 'ferret'));34users.push(new User('Jane', 6, 'ferret'));35users.push(new User('Luna', 1, 'cat'));36users.push(new User('Manny', 1, 'cat'));