upsert = [ update +insert ]
Upsert  is the feature in the Mongo DB used while updating the records with Update Query.

While Updating the records using update(), if particular record exists it will update with the provided data, else it will not update. If we use Upsert it will create the record with particular data if the data doesn’t already exists. Find the below example.
InitialData:

{    "Student_name" : "Raja",    "Department" : "Computer Science and Engg",    "Marks" : [69, 78, 88,95]  }
 {    "Student_name" : "Rahul",    "Department" : "Computer Science and Engg",    "Marks" : [59, 74, 80]  }

Here am trying to update the data which is not in the DataBase, so it will insert the new row in the Database, Query follows as below.

db.studentDetails.update
(
    {
     Student_name:'Venkat'  
    },
    {
        Student_name:'Venkat',
        Department:'EEE',
        Percentage:'99%'
    },
    {
        upsert:true
    }
)

And new record will be inserted into the database and record will look like as below.
{ "Student_name" : "Venkat", "Department" : "EEE",    "Percentage" : "99%" }