title: Get _id from MongoDB using Scala
body: <p>For a given JSON how do I get the _id to use it as an id for inserting in another JSON?</p>
  
  <p>Tried to get the ID as shown below but does not return correct results.</p>
  
  <pre class="lang-scala prettyprint-override"><code>private def getModelRunId(): List[String] = {
    val resultsCursor: List[DBObject] =
      modelRunResultsCollection.find(MongoDBObject.empty, MongoDBObject(FIELD_ID -&gt; 1)).toList
    println("resultsCursor &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; " +  resultsCursor)
    resultsCursor.map(x =&gt; (Json.parse(x.toString()) \ FIELD_ID).asOpt[String]).flatten
  }
  </code></pre>
  
  <pre><code>{
  "_id": ObjectId("5269723bd516ec3a69f3639e"),
  "modelRunId": ObjectId("5269723ad516ec3a69f3639d"),
  "results": [
  {
    "ClaimId": "526971f5b5b8b9148404623a",
    "pricingResult": {
      "TxId": 0,
      "ClaimId": "Large_Batch_1",
      "Errors": [
  
      ],
      "Disposition": [
        {
          "GroupId": 1,
          "PriceAmt": 20,
          "Status": "Priced Successfully",
          "ReasonCode": 0,
          "Reason": "RmbModel(PAM_DC_1):ProgramNode(Validation CPG):ServiceGroupNode(Medical Services):RmbTerm(RT)",
          "PricingMethodologyId": 2,
          "Lines": [
            {
              "Id": 1
            }
          ]
        }
      ]
    }
  },
  </code></pre>