title: Mongoose Models in Express App (not found by require)
body: <p>I am trying to define a simple Mongoose model for a learning ExpressJS app. </p>
  
  <pre><code># Todo.coffee
  
  mongoose = require "mongoose"
  Schema = mongoose.Schema
  
  todoSchema = new Schema 
      title: String
      desc: String
      dueOn: Date
      completedOn: Date
  
  Todo = new mongoose.model("Todo", todoSchema)
  </code></pre>
  
  <p>I have a <code>Todos</code> class that is meant for other classes to use. (Not sure if its better to just use the <code>Todo</code> model tho?)</p>
  
  <pre><code># Todos.coffee
  
  Todo = require "Todo"
  
  class Todos 
  
      byId: (id, callback) -&gt;
          Todo.findOne { _id: id }, callback
  </code></pre>
  
  <p>Then in my Mocha/should unit test ... </p>
  
  <pre><code>require "should"
  Todos = require "../../../app/todos/Todos.coffee"
  Todo = require "../../../app/todos/Todo.coffee"
  
  describe "Todos", -&gt;
      describe "byId", -&gt;
          it "should return Todo with given ID", (done) -&gt;
              Todos.byId 1, (err, todo) -&gt;
                  todo.should.be.an.instanceOf(Todo)
                  done()
  </code></pre>
  
  <p>But I am getting ... </p>
  
  <pre><code>$ mocha --compilers coffee:coffee-script tests/backend/todos/TodosTests.coffee 
  
  module.js:340
      throw err;
            ^
  Error: Cannot find module 'Todo'
      at Function.Module._resolveFilename (module.js:338:15)
      at Function.Module._load (module.js:280:25)
      at Module.require (module.js:362:17)
      at require (module.js:378:17)
      at Object.&lt;anonymous&gt; (/labs/Projects/Tickle/app/todos/Todos.coffee:4:10)
      at Object.&lt;anonymous&gt; (/labs/Projects/Tickle/app/todos/Todos.coffee:20:4)
      at Module._compile (module.js:449:26)
      at Object.require.extensions..coffee (/usr/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:22:21)
  </code></pre>
  
  <p>What did I do wrong? </p>