title: Relate children to parent using Mongo aggregate query
body: <p>I have a single collection named assets that contains documents in 2+ formats, ParentObject and ChildObject.  I am currently associating ParentObject to ChildObject with two queries.  Can this be done with an aggregate query?</p>
  
  <p>ParentObject</p>
  
  <pre><code>{
      "_id" : {
          "oid" : "ParentFooABC",
          "brand" : "acme"
      },
      "type": "com.ParentClass",
      "title": "Title1234",
  
      "availableDate": Date,
      "expirationDate": Date
  }
  </code></pre>
  
  <p>ChildObject</p>
  
  <pre><code>{
      "_id" : {
          "oid" : "ChildFoo",
          "brand" : "acme"
      },
      "type": "com.ChildClass",
      "parentObject": "ParentFooABC",
      "title": "Title1234",
      "modelNumber": "8HE56",
      "modelLine": "Metro",
      "availableDate": Date,
      "expirationDate": Date,
      "IDRequired": true
  }
  </code></pre>
  
  <p>Currently I filter data like this</p>
  
  <pre><code>val parent = db.asset.find(MongoDBObject("_id.brand": MongoDBObject($eq: "acme")),MongoDBObject("type":"com.ParentClass"))
  val children = db.asset.find(MongoDBObject("_id.brand": MongoDBObject($eq: "acme")),MongoDBObject("type":"com.ChildClass"), MongoDBObject("parentObject": "${parent._id.oid}"))
  if(childs.nonEmpty) {
    //I have confirmed this parent has a child associated and should be returned
    val childModelNumbers = childs.map(child -&gt; child.modelNumber)
    val response = ResponseObject(parent, childModelNumbers)
  }
  </code></pre>
  
  <p>Can I do this in an aggregate query?</p>
  
  <p><strong>Updated</strong>:  </p>
  
  <p>Mongo Version:  db version v2.6.11</p>
  
  <p>Language: Scala </p>
  
  <p>Driver: Casbah 2.8.1</p>