Standardmäßig ist der Prompt ausgewählt, der zuerst die Quelle prüft. Sie können zu einem direkten Befehl wechseln oder eine lokale Kopie herunterladen.
Quelldateien prüfen
Lesen Sie SKILL.md und alle von SkillsMP angezeigten Begleitdateien, bevor Sie sich für eine Installation entscheiden.
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fügen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prüfen und installieren.
Ein direkter Befehl überspringt den Prüf-Prompt. Prüfen Sie die Quelle, bevor Sie ihn ausführen.
MongoDB is a document-oriented NoSQL database that stores data in flexible, JSON-like documents. It excels at handling unstructured or semi-structured data, hierarchical relationships, and scenarios requiring horizontal scaling.
Key Features:
Flexible schema (schemaless documents)
Rich query language with secondary indexes
Aggregation framework for analytics
Horizontal scaling (sharding)
Replica sets for high availability
Change streams for real-time data
Geospatial and full-text search
When to Use MongoDB:
Rapidly evolving schemas
Hierarchical/nested data (embedded documents)
Real-time analytics with aggregation
Geospatial applications
Content management systems
IoT data ingestion
Catalog/inventory systems
When NOT to Use MongoDB:
Complex multi-table joins (use RDBMS)
ACID transactions across many documents (improved in 4.0+, but limited)
// Spring Boot configuration
spring:
data:
mongodb:
uri: mongodb://localhost:27017/mydb
auto-index-creation: false # Create indexes manually in production
# Connection pool settings(via URI)
# mongodb://localhost:27017/mydb?maxPoolSize=50&minPoolSize=10&maxIdleTimeMS=30000
Query Optimization
// Use projections to limit returned fields
db.users.find({ status: "active" }, { name: 1, email: 1 })
// Use hint to force specific index
db.users.find({ status: "active" }).hint({ status: 1, createdAt: -1 })
// Limit results for pagination
db.users.find().sort({ createdAt: -1 }).skip(20).limit(10)
// Use $exists: false for missing fields (can use index)
db.users.createIndex({ optionalField: 1 }, { sparse: true })
db.users.find({ optionalField: { $exists: true } })
Schema Optimization
// Avoid large arrays (cap at reasonable size)// Use bucketing pattern for time-series data
{
_id: "sensor1_2024-01-15",
sensorId: "sensor1",
date: ISODate("2024-01-15"),
readings: [
{ ts: ISODate("..."), value: 23.5 },
{ ts: ISODate("..."), value: 24.1 },
// ... up to N readings per bucket
],
count: 288// Track count for full bucket detection
}
// Pre-aggregate for reporting
{
_id: "stats_2024-01",
month: "2024-01",
totalOrders: 1523,
totalRevenue: 152300.50,
avgOrderValue: 100.00,
topProducts: ["SKU001", "SKU002", "SKU003"]
}
Best Practices
1. Schema Design
// Embed when: data is queried together, bounded arrays// Reference when: unbounded arrays, many-to-many, independent access// Use extended reference pattern for frequently accessed fields
2. Indexing
// Create indexes for query patterns, not just fields// Use compound indexes following ESR rule// Monitor slow queries: db.setProfilingLevel(1, { slowms: 100 })// Avoid indexing low-cardinality fields alone
3. Write Operations
// Use bulk operations for multiple writes// Avoid unbounded array growth// Use write concern appropriate to durability needs
db.orders.insertOne(doc, { writeConcern: { w: "majority" } })
4. Read Operations
// Always use projections to limit returned data// Use explain() to verify index usage// Prefer aggregation over multiple queries// Use read preference for scaling reads
db.orders.find().readPref("secondaryPreferred")
5. Connection Management
// Use connection pooling// Set appropriate pool size (default: 100)// Handle connection errors with retry logic// Close connections properly on shutdown
Common Pitfalls
Unbounded array growth:
// BAD: Comments array grows forever
{ _id: "post1", comments: [...thousands of comments...] }
// GOOD: Separate collection with references
{ _id: "comment1", postId: "post1", text: "..." }
Missing indexes:
// Always create indexes for query patterns// Check with explain() - look for COLLSCAN (bad)
db.users.find({ email: "..." }).explain()
Over-indexing:
// Each index adds write overhead// Only index fields used in queries// Monitor index usage: db.users.aggregate([{ $indexStats: {} }])