Working with Documents
Inserting Documents
You can insert a single document into a collection using the insert()
method:
To insert multiple documents at once, use the insertMany()
method:
Displaying Documents
To retrieve and display documents from a collection, use the find()
method:
This will return all documents in the collection.
You can also format the output for better readability using the pretty()
method:
Displaying Collections
To list all collections in the current database, use the show collections
command:
To view statistics and information about a specific collection, use the stats()
method:
Last updated
Was this helpful?