Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Show all collections in the current database

show collections

Create collection

db.CreateCollection("my_collection")
db.createCollection("my_collection", { capped: true, size: 5242880, max: 5000 })

Rename collection

db.my_collection.renameCollection("new_collection")

Count documents

db.my_collection.countDocuments()
db.my_collection.countDocuments({ active: true })

Delete collection

db.my_collection.drop()

Show collection statistics

db.my_collection.stats()