title: mongoose find document by subdocument's _id
body: <p>Let say I have the following structure:</p>
  
  <pre><code>var Partner = require('../partner/partner.model');
  
  var ContractSchema = new Schema({
        // blahblah
        partners: [Partner.schema]
  });
  </code></pre>
  
  <p>So here every contract has an array of partners, and each partner has an <code>_id</code> property.</p>
  
  <p>I want to search for a contract, which has a partner with a specific <code>_id</code>.
  I tried this, but didn't work:</p>
  
  <pre><code>  var ObjectId = require('mongoose').Types.ObjectId;    
    Contract.find({
        partners: {
          $elemMatch: {
            _id: {
              $eq: new ObjectId(req.query.partnerId)
            }
          }
        }
      }, function (err, serviceContracts) {
        if (err) {
          return handleError(res, err);
        } else {
          return res.status(200).json(serviceContracts);
        }
      });
  </code></pre>
  
  <p><b>EDIT:</b> Here's an example what I have in the db:</p>
  
  <pre><code>{
      "_id" : ObjectId("57e370e72beac9fc21c99ca3"),
      "updatedAt" : ISODate("2016-09-22T05:49:27.000Z"),
      "createdAt" : ISODate("2016-09-22T05:49:27.000Z"),
      "currency" : "USD",
      "partners" : [ 
          {
              "updatedAt" : ISODate("2016-09-22T05:49:27.000Z"),
              "createdAt" : ISODate("2016-09-22T05:49:27.000Z"),
              "name" : "Apple Inc.",
              "_id" : ObjectId("57e370e72beac9fc21c99caa")
          }
      ],
      "__v" : 0
  }
  </code></pre>