get _id with mongoose
<p>I was trying to console.log(record._id) all of records on my mongodb collection using Mongoose. I kept getting <code>undefined</code> for each of the _id values. </p>

<p>I struggled until I bumped into <a href="https://stackoverflow.com/questions/18710043/mongoose-mongodb-result-fields-appear-undefined-in-javascript">this post</a>. Then I used console.dir to find the location of the _id and used that in my console.log:</p>

<pre><code>MySchemaModel.find({}).then(function(records) {

  records.forEach(function(record) {

    console.log(record._doc._id); // &lt;-- I added ._doc
  });

});
</code></pre>

<p>But, this looks down-right hacky. Is there a better way to do this?</p>

<p>NOTE: This isn't just something that affects console.log. I'm just keeping the question narrow.</p>