title: Mongoose populate with array of objects containing ref
body: <p>I have a Mongoose schema with an array <code>lists</code> of objects that consist of a reference to another collection and a nested array of numbers:</p>
  
  <pre><code>var Schema, exports, mongoose, schema;
  
  mongoose = require("mongoose");
  
  Schema = mongoose.Schema;
  
  schema = new Schema({
    name: {
      type: String,
      required: true,
      unique: true,
      trim: true
    },
    lists: [
      {
        list: {
          type: Schema.ObjectId,
          require: true,
          ref: "List"
        },
        allocations: [
          {
            type: Number,
            required: true
          }
        ]
      }
    ],
    createdAt: {
      type: Date,
      "default": Date.now
    },
    updatedAt: {
      type: Date
    }
  });
  
  exports = module.exports = mongoose.model("Portfolio", schema);
  </code></pre>
  
  <p>However, I cannot get <code>populate</code> to work as expected without getting a <code>TypeError: Cannot read property 'ref' of undefined</code>. I've tried <code>populate('list')</code> and <code>populate('lists list')</code> but I'm either not calling things correctly or my Schema isn't formed correctly. I don't have this problem if I simply reference the lists by themselves:</p>
  
  <pre><code>lists: [
      {
          type: Schema.ObjectId,
          require: true,
          ref: "List"
      }
    ]
  </code></pre>
  
  <p>but I want to have the allocations array alongside each list. What do I need to do to get the behavior I want?</p>