I am using mongoose.findOneAndUpdate() method for inserting and updating a document in the collection. However if there is nothing to update in the table and a new document is created, the findOneAndUpdate() callback returns null.
How would I know if the insert part of the findOneAndUpdate() was successfull?
TimeTable.getTimeTableModelObject().findOneAndUpdate({ageGroup:'2'}, timeTable, {upsert:true}, function(err, foundData){});