title: Trying to populate my user model and getting a Type Error
body: <p>In my program I want to populate my index page with a model called a group. Previously I just showed all the groups that existed in the database, but now I want to only show the groups that the user who is logged in is associated with. </p>
  
  <p>Here are the models:
  Group Model</p>
  
  <pre><code>var mongoose = require("mongoose");
  
  var groupSchema = new mongoose.Schema({
  
      name: String,
      thumbnail: String,
      description: String,
      author: {
          id: {
              type: mongoose.Schema.Types.ObjectId,
              ref: "User"
          },
          username: String
      },
      inviteCode: String,
      images: [
          {
              type: mongoose.Schema.Types.ObjectId,
              ref: "Image"
  
          }
      ],
      users: [
          {
             type: mongoose.Schema.Types.ObjectId,
             ref: "User"
          }
      ] });
  
  module.exports = mongoose.model("Group", groupSchema);
  </code></pre>
  
  <p>User Model</p>
  
  <pre><code>var mongoose = require("mongoose");
  var passportLocalMongoose = require("passport-local-mongoose");
  
  var UserSchema = new mongoose.Schema({
      username: String,
      password: String,
      groups: 
          [
              {
                  type: mongoose.Schema.Types.ObjectId, //referencing model by id
                  ref: "Group" //name of the model
              }
          ],
      images: 
          [
              {
                  type: mongoose.Schema.Types.ObjectId, //referencing model by id
                  ref: "Image" //name of the model
              }
          ]
  });
  
  UserSchema.plugin(passportLocalMongoose); //add in local mongoose methods to user
  
  module.exports = mongoose.model("User", UserSchema);
  </code></pre>
  
  <p>My Index Route:</p>
  
  <pre><code>//Index Route
  router.get("/", middleware.isLoggedIn, function(req, res){
      var user = req.user;
      user.populate("groups").exec(function(err, allGroups){ 
         if(err){
             console.log(err);
         } else {
             res.render("groups/show", {groups: allGroups});
             console.log(allGroups);
         }
     });
  });
  </code></pre>
  
  <p>And this is the error I get:</p>
  
  <blockquote>
    <p>TypeError: user.populate(...).exec is not a function</p>
  </blockquote>
  
  <p>I am not sure why I cant use the populate method with my user model, can someone explain me an alternative to achieve the desired outcome. Thank you.</p>