Lets learn to use upsert option with update() method. upsert basically inserts document into the collection, if there is no…