text: /**
   * Created by 斌 on 2017/4/16.
   */
  const mongoose = require('mongoose');
  Schema = mongoose.Schema;
  
  var personSchema = Schema({
      _id     : Number,
      name    : String,
      age     : Number,
      stories : [{ type: Schema.Types.ObjectId, ref: 'Story' }]
  });
  var storySchema = Schema({
      _creator : { type: Number, ref: 'Person' },
      title    : String,
      fans     : [{ type: Number, ref: 'Person' }]
  });
  var Story  = mongoose.model('Story', storySchema);
  var Person = mongoose.model('Person', personSchema);
  //
  // var aaron = new Person({ _id: 0, name: 'Aaron', age: 100 });
  // aaron.save(function (err) {
  //     if (err) {
  //         console.log(err);
  //         return
  //     }
  //
  //     var story1 = new Story({
  //         title: "Once upon a timex.",
  //         _creator: aaron._id    // assign the _id from the person
  //     });
  //
  //     story1.save(function (err) {
  //         if (err) {
  //             console.log(err);
  //             return;
  //         }
  //         // thats it!
  //     });
  // })
  Person.findOne({name: 'Aaron'})
      .exec((err, doc) => {
  
          var opts = [{
              path:'stories'
          }]
  
          doc.populate(opts, (err, pdoc) => {
              console.log(pdoc);
          })
  
      })
  
  Story
      .findOne({ title: 'Once upon a timex.' })
      .populate('_creator')
      .exec(function (err, story) {
          console.log('The creator is %s', story._creator.name);
          // prints "The creator is Aaron"
      })
  