title: RestMVC.js(Mongoose) & Node.JS - External model files
body: <p>I am using RestMVC.js module that uses Mongoose in turn for model declaration. Let's say I have a few files with model declarations, and a few of them use those classes for member variable ala:</p>
  
  <pre><code>// Foo.js file
  module.exports.Foo = function(mongoose)
  {
    var Schema = mongoose.Schema;
  
    var Foo = mongoose.model('Foo', new Schema({
     TestMember: String,
     SecondTestMember: Date
    }));
  
    return mongoose.model('Foo');
  };
  
  // Bar.js file
  module.exports.Bar = function(mongoose)
  {
     var Schema = mongoose.Schema;
  
     var Bar = mongoose.model('Bar', new Schema({
     DerivedMember: Foo,
     Blah: String
    }));
  
    return mongoose.model('Bar');
  };
  </code></pre>
  
  <p>What is the correct approach to reference one model from the other? I attempted to do require('models/Foo.js') and exports.Foo as well as mongoose.exports.Foo to no avail.</p>