title: Embedded array push not working in mongoose - push not defined
body: <p>Hie,</p>
  
  <p>I have a schema of this format.</p>
  
  <pre><code>var parentSchema = mongoose.Schema({
      username: { type: String, required: true, index: { unique: true } },
      password: { type: String, required: true },
      parent_id : Schema.Types.ObjectId,
      country_id : Schema.Types.ObjectId,
      child: [childSchema]
  });
  
  var childSchema = mongoose.Schema({
      child_name: String,
      standard_id: Schema.Types.ObjectId,
      child_id : Schema.Types.ObjectId,
      total_gold: { type: Number},
      total_diamonds:{ type: Number },
      total_hearts: { type: Number},
      subjects: [subjectSchema]
  });
  
  var subjectSchema = mongoose.Schema({
      subject_name :String,
      grade_name : String,
      games: [gameSchema]
  });
  
  var gameSchema = mongoose.Schema({
      id:Schema.Types.ObjectId,
      game_id: Schema.Types.ObjectId,
      gold: { type: Number },
      diamonds: { type: Number },
      hearts: { type: Number },
      plays: { type: Number },
      best_score: { type: Number },
      is_locked: String
  });
  </code></pre>
  
  <p>Iam trying to insert data into the models this way.</p>
  
  <pre><code>var parent = new Parent();
  parent.username = req.body.username;
  parent.password = req.body.password;
  
  var games = new Games({gold:0,diamonds:0,hearts:0,plays:0,best_score:0,is_locked:false});
  
  
  var subjects = new Subjects({subject_name:req.body.subjectname,grade_name:req.body.gradename});
  
  var child = new Child({child_name:req.body.childname,total_gold:0,total_diamonds:0,total_hearts:0});
  </code></pre>
  
  <p>After the data is inserted into models iam adding the models to parent document this way.</p>
  
  <pre><code>subjects.games.push(games);
  child.subjects.push(subjects);
  parent.child.push(child);
  parent.save(function (err, parent) {
      if (err)
          throw err;
  });
  </code></pre>
  
  <p>When i using the above code iam getting error saying push is undefined for subjects.</p>
  
  <p>Error stack is as follows:</p>
  
  <pre><code> subjects.games.push(games);
                             ^
   TypeError: Cannot call method 'push' of undefined
  at Promise.module.exports.saltAndHash (d:\BWApis\BWApiProject\app\server\router.js:926:32)
  at Promise.onResolve (d:\BWApis\BWApiProject\node_modules\mongoose\node_modules\mpromise\lib\promise.js:177:8)
  at Promise.EventEmitter.emit (events.js:95:17)
  at Promise.emit (d:\BWApis\BWApiProject\node_modules\mongoose\node_modules\mpromise\lib\promise.js:84:38)
  at Promise.fulfill (d:\BWApis\BWApiProject\node_modules\mongoose\node_modules\mpromise\lib\promise.js:97:20)
  at Object.cb (d:\BWApis\BWApiProject\node_modules\mongoose\lib\query.js:1145:30)
  at Object.exports.tick (d:\BWApis\BWApiProject\node_modules\mongoose\node_modules\mquery\lib\utils.js:137:16)
  at processImmediate [as _immediateCallback] (timers.js:330:15)
  </code></pre>