title: Mongoose adds _id to all nested objects
body: <p>When creating a document with nested objects (e.g. an array of objects), each object is given its own _id. For example, my schema looks like this:</p>
  
  <pre><code>mongoose = require "mongoose"
  
  Schema = mongoose.Schema
  
  schema = new Schema
    name:
      type: String
      required: true
      unique: true
      trim: true
  
    lists: [
      list:
        type: Schema.Types.ObjectId
        required: true
        ref: "List"
      allocations: [
        allocation:
          type: Number
          required: true
      ]
    ]
  
    createdAt:
      type: Date
      default: Date.now
  
    updatedAt:
      type: Date
  
  # Ensure virtual fields are serialised.
  schema.set "toJSON",
    virtuals: true
  
  exports = module.exports = mongoose.model "Portfolio", schema
  </code></pre>
  
  <p>Every object in the <code>lists</code> array is given an _id, as is every <code>allocation</code> object in the <code>lists.allocations</code> array, when documents are eventually created. This seems like overkill and bloats the document, but is there a reason MongoDB (or Mongoose) needs the document to contain this additional information? If not, I'd like to prevent it from happening so that the only _id is on the root document.</p>
  
  <p>Furthermore, Mongoose automatically creates a virtual <code>id</code> for <code>_id</code>, which I need because my client code expects a field <code>id</code>. This is why I'm having virtuals returned with JSON. However, because there are <code>_id</code> fields all throughout the document, not just at the root, this virtual duplicates <em>all</em> of them. If there is no way to prevent the additional _id fields, how can I get a virtual to only apply only to the root document _id? Or if there is a better way to do what I'm trying to do with it, what would it be?</p>