db.createCollection()
Reference group: Database and collection discovery
What it does
Explicitly creates a collection with options such as validation or capped behavior.
Syntax
db.createCollection(name, options)
Use case
Create a collection with specific settings.
db.createCollection(): practical example
db.createCollection("events", { capped: true, size: 1048576 })💡 Explanation
Explicitly creates a collection with options such as validation or capped behavior.
When to use it
Create a collection with specific settings.
Key Takeaways
- Explicitly creates a collection with options such as validation or capped behavior.
- Typical use: Create a collection with specific settings.