MongoDB Shell and Connection Basics/Insert one sample document

Create a starter document.

Section: Collection bootstrap

Insert one sample document

javascript
javascript
db.users.insertOne({ name: "Ada", email: "ada@example.com", active: true })
Explanation

A collection will be created automatically if it does not already exist.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Collection bootstrap
Create a collection
Create a collection explicitly.
OpenIn sheetjavascriptsame section
Read a few documents
Preview documents from a collection.
OpenIn sheetjavascriptsame section
Pretty-print query results
Format documents for easier reading.
OpenIn sheetjavascriptsame section
Drop a collection
Remove a collection and its data.
OpenIn sheetjavascriptsame section
List databases
Show visible databases in the deployment.
OpenIn sheetjavascript1 tag match
Switch database
Change the current database context.
OpenIn sheetjavascript1 tag match