title: How do I find documents using multiple conditions?
body: <p>I have looked at other posts and none seem to address what I'm trying to do. I need to create a query that searches for all records that have type_ids in an array, AND belong to the current logged in user. Here is what I have:</p>
  
  <p>Query:</p>
  
  <pre><code>app.post('/photos', function(req, res) {
      Photos
          .find({
              'type_id': { $in: req.body.type_ids },
              $and : {'groups.users': { $in: req.user._id }}
          })
          .select('name size')
          .exec(function(err, data) {
              return res.json(data);
          });
  });
  </code></pre>
  
  <p>Schema:</p>
  
  <pre><code>var photoSchema = mongoose.Schema({
      name : String,
      size : String,
      type_id : String,
      created : {
          type: Date,
          default: Date.now
      },
      groups : {
          users : [],
          other : []
      }
  });
  </code></pre>
  
  <p>The only thing I can get to work is the following query:</p>
  
  <pre><code>app.post('/photos', function(req, res) {
      Photos
          .find({'type_id': { $in: req.body.type_ids }})
          .select('name size')
          .exec(function(err, data) {
              return res.json(data);
          });
  });
  </code></pre>
  
  <p>But, obviously this won't work because I only want those results for a particular user. The line <code>$and : {'groups.users': { $in: req.user._id }}</code> clearly isn't working, but I'm not sure how to fix it. Any ideas?</p>