save() - Save a document command
Saves an inserted or updated JSON document in a collection. If a document in a collection has the same ID as a new document, the existing document is replaced. Otherwise, the new document is inserted.
Syntax diagram
Command parameters
- document
- This parameter specifies the JSON document to save.
Example
Save a JSON document in a collection:
db.books.save({isbn: "123-456-239",
"author": "Verne, Jules", "title": "Mysterious Island" })
Sample
output is as follows:OK