title: Cannot read property 'users' of undefined
body: <p>I'm new to MongoDB and have a database of users. I'm trying it such that a user can click on a button of their favorite shoes and it updates the database. My schema is as follows: </p>
  
  <pre><code>var mongoose = require('mongoose');
  var bcrypt   = require('bcrypt-nodejs');
  
  // define the schema for our user model
  var userSchema = mongoose.Schema({
      local            : {
          email        : String,
          password     : String,
      }, 
  });
  
  // methods ======================
  // generating a hash
  userSchema.methods.generateHash = function(password) {
      return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null);
  };
  
  // checking if password is valid
  userSchema.methods.validPassword = function(password) {
      return bcrypt.compareSync(password, this.local.password);
  };
  
  // create the model for users and expose it to our app
  module.exports = mongoose.model('User', userSchema);
  </code></pre>
  
  <p>Posting DB function: </p>
  
  <pre><code>exports.addToFavs = function(req, res) {
      var size_result = req.query.size;
      var brandToFind = req.query.brandToFind;
      req.db.users.update({email: req.user.email}, {$set: favoriteShoes[{name: brandToFind, size: size_result}]}); /*, function(error, favoriteShoes) {
          if (error) return next(error); 
          if (!favoriteShoe) return next(new Error('Failed to save')); */
          console.info('Added %s with id=%s', brandToFind, size_result);
          res.redirect('/favorites');
      //})
  }; 
  </code></pre>
  
  <p>HTML Button: </p>
  
  <pre><code>&lt;form action="/result" method="post"&gt;
              &lt;center&gt;&lt;button&gt;Save to Favorites&lt;/button&gt;&lt;/center&gt;
            &lt;/form&gt;
  </code></pre>
  
  <p>Appropriate Routes: </p>
  
  <pre><code>app.post('/result', searchResults.addToFavs); 
  </code></pre>
  
  <p>I'm really confused about how to get this to work... somehow it can't read by db table "users" (validated through the console that this is what the table is called) so trying to get it to work but it's not working... </p>