title: Is it possible to reference two schemas to eachother in Mongoose?
body: <p>I have two Schemas, and I want to be able to access both of them from the other one.. I am trying to do something like this: </p>
  
  <p>//email.js</p>
  
  <pre><code>var mongoose = require('mongoose')
      ,Schema = mongoose.Schema
      , FoodItemSchema = require('../models/fooditem.js')
      , UserSchema = require('../models/user.js').schema
      , User = require('../models/user.js').model
  
      console.log(require('../models/user.js'));
  
      var emailSchema = new Schema({
          From : String,
          Subject : FoodItemSchema,
          Body : String,
          Date: Date,
          FoodItems : [FoodItemSchema],
          Owner : { type : Schema.Types.ObjectId , ref: "User" }
      });
  
      module.exports = {
          model: mongoose.model('Email', emailSchema),
          schema : emailSchema 
      }
  </code></pre>
  
  <p>//user.js</p>
  
  <pre><code>var mongoose = require('mongoose')
      ,Schema = mongoose.Schema
      , Email = require('../models/email.js').model
      , EmailSchema = require('../models/email.js').schema
  
  
  console.log(require('../models/email.js'));
  
  var userSchema = new Schema({
      googleID : String,
      accessToken : String,
      email : String,
      openId: Number,
      phoneNumber: String,
      SentEmails : [EmailSchema]
      // Logs : [{type: Schema.ObjectId, ref: 'events'}]
  });
  module.exports =  {
      model :  mongoose.model('User', userSchema),
      schema : userSchema
  }
  </code></pre>
  
  <p>The first console.log() prints empty string and the second one prints as expected. I feel like I am trying to get the variables in the other schema even before they were created. Is there a common workaround for this? Or should I avoid double dependencies in my design? </p>