Is there an “upsert” option in the mongodb insert command?

Technology CommunityCategory: MongoDBIs there an “upsert” option in the mongodb insert command?
VietMX Staff asked 3 years ago

Since upsert is defined as operation that creates a new document when no document matches the query criteria there is no place for upserts in insert command. It is an option for the update command.

db.collection.update(query, update, {upsert: true})