title: Unable to Insert Data into a collection
body: <p>I have officer Schema in which if a user wants to fix an appointment, his entry is made in the DB. The schema is:</p>
  
  <pre><code>officerSchema = mongoose.Schema({
      email : {type: String,
          index: { unique: true }
      },
      appointmentList : Array // array of jsonObject of dates and userID
  });
  </code></pre>
  
  <p>The AppointmentList is an array of JSON Objects which contains the ID of the officer with which appointment has to be made, date and userID (the user which wants to fix the appointment).</p>
  
  <p>However to avoid duplicate appointment entries, I have been using several methods mentioned on the internet. None of them have worked for me so far. I am posting the code below. The problem with below code is it NEVER inserts any data in the appointmentsList. However if I use <strong>save()</strong> instead of <strong>update()</strong> insertion occurs but duplicates also get inserted.</p>
  
  <p>Here is the JSON Object that I want to add in the array from DB,</p>
  
  <pre><code>{
      "id": "1321231231",
      "appointment": {
          "userID": "31321",
          "date": "24 March"
      }
  }
  
  var ID = requestObject.id; 
  var newObject =  {$addToSet: requestObject.appointment};
  OfficerModel.findOne({_id : ID}, function(err, foundData) {
      if(err) {
          console.log(err);
          return;
      }
      else {
              var dbList = foundData.list;
              dbList.push(newObject);
              foundData.update(function(err, updatedData) {
                  if(err) {
                      console.log( err);
                  }
                  else {
                      console.log("successful");
                  }
              });
      }
  });
  </code></pre>