title: How to save multiple refs to other documents in MongoDB using Mongoose?
body: <p>I am trying to find out the way how I could save multiple references to other documents in MongoDB using Mongoose. Is not a big deal to save one reference to other document, but it gets quickly complicated when you want to save multiple references to other documents and populate them later.</p>
  
  <p>Let's look at what I have:</p>
  
  <pre><code>var mongoose = require('mongoose'),
          Schema = mongoose.Schema;
  
  var Book = Schema({
      title: String,
    reviews: [{ type: Schema.Types.ObjectId, ref: 'Review' }]
  });
  
  var Review = Schema({
      body: String
  });
  
  var Book  = mongoose.model('Book', bookSchema);
  var Review = mongoose.model('Book', reviewSchema);
  
  var reviewItem = new Review({body: "review content"});
  
  Book.find({}).exec(function(err, collection) {
      if(collection.length === 0) {
  
          reviewItem.save(function (err) {
              if (err) return handleError(err);
  
              var bookItem = new Book({
                  title: "book title",
                  reviews: reviewItem._id
              });
  
              bookItem.save(function (err) {
                  if (err) return handleError(err);
              })
          })
  
      }
  })
  </code></pre>
  
  <p>In this example I am saving <code>reviewItem</code> with reference to it in <code>bookItem</code>, but I would like to save an array of <code>reviewItem</code> objects with array of references in <code>bookItem</code>. How I could do that? </p>
  
  <p>The result I am expecting when <code>Book</code> is populated:</p>
  
  <pre><code>[
    {
      "_id": "547b1a4685207124a085d0c5",
      "title": "The Enterprise And Scrum",
      "reviews": [
        {
          "_id": "547b1a4685207124a085d0c3",
          "body": "review 1"
        },
        {
          "_id": "543d99564d01f3de94655ba2",
          "body": "review 2"
        },
        {
          "_id": "543d995625755d19ba72863d",
          "body": "review 3"
        }
      ]
    }
  ]
  </code></pre>