Section: Collection bootstrap

Create a collection

javascript
javascript
db.createCollection("users")
Explanation

MongoDB can also create collections implicitly on first insert, but explicit creation is useful for options and predictability.

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
Drop a collection
Remove a collection and its data.
OpenIn sheetjavascriptsame section
Insert one sample document
Create a starter document.
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
List databases
Show visible databases in the deployment.
OpenIn sheetjavascript1 tag match
Switch database
Change the current database context.
OpenIn sheetjavascript1 tag match