title: Function is not defined - module.exports - Express
body: <p>I have a strange behavior in my Express app which I cannot understand. I have a user model file (user.js) which contains some schemas and some functions. When I require the file from my routes file (users.js) I can access Schemas but cannot call functions as they return 'myFunc is not a function'. This happens only in case I have multiple schemas, in case of one schema everything is perfect. Could you please help me to figure out?</p>
  
  <p>This one returns: userModels.User.addUser is not a function</p>
  
  <p>user.js</p>
  
  <pre><code>...
  const UserModels = module.exports = {
      'User': mongoose.model('User', UserSchema),
      'Token': mongoose.model('Token', TokenSchema)
  }
  
  module.exports.addUser = function(newUser, callback){
      console.log('test');
  }
  ...
  </code></pre>
  
  <p>users.js</p>
  
  <pre><code>...
  userModels.User.addUser(newUser, function(err, user){
      if(err){
          res.json({success: false, msg: "Failed to register."});
      } else{
          res.json({success: true, msg: 'User has been registered'});
      }
  });
  ...
  </code></pre>
  
  <p>This one passes:</p>
  
  <pre><code>...
  
  const User = module.exports = mongoose.model('User', UserSchema);
  
  module.exports.addUser = function(newUser, callback){
      console.log('test');
  }
  
  ...
  
  User.addUser(newUser, function(err, user){
      if(err){
          res.json({success: false, msg: "Failed to register."});
      } else{
          res.json({success: true, msg: 'User has been registered'});
      }
  });
  
  ...
  </code></pre>