title: MongoDB + Node.js : How to use a Schema from an external file for another Schema?
body: <p>I have a classes (or models) that needs to use another class as part of its properties as shown below.</p>
  
  <p>** Header for both files **</p>
  
  <pre><code>var mongoose = require('mongoose'),
  Schema =       mongoose.Schema;
  </code></pre>
  
  <p><strong>item.js</strong></p>
  
  <pre><code>module.exports = function() {
      var ItemSchema = new Schema({
          name: String,
          cost: Number
      });
      mongoose.model('Item', ItemSchema);
  }
  </code></pre>
  
  <p><strong>receipt.js</strong></p>
  
  <pre><code>ItemModel = require('./item.js');
  
  var Item = mongoose.model('Item');
  
  module.exports = function() {
  
      var LineItemSchema = new Schema({
          item:   Item,
          amount: Number
      });
  
      var LineItem = mongoose.model('LineItem', LineItemSchema);
  
      var ReceiptSchema = new Schema({
          name:   String,
          items:  [LineItemSchema]
      });
      mongoose.model('Receipt', ReceiptSchema);
  }
  </code></pre>
  
  <p>In the LineItem class, I'm trying to set the type of the variable 'item' to the class type, Item, node.js or mongoose.js is screaming at me about it saying that there's a type error. </p>
  
  <p>How can I use a Schema "type" from an external file?</p>