AI Skill Report Card

Working with MongoDB

B75·Jun 15, 2026·Source: Web

MongoDB Development

15 / 15
JavaScript
// Connect and perform basic operations const { MongoClient } = require('mongodb'); const client = new MongoClient('mongodb://localhost:27017'); await client.connect(); const db = client.db('myapp'); const collection = db.collection('users'); // Insert document await collection.insertOne({ name: 'John Doe', email: 'john@example.com', createdAt: new Date() }); // Query with index-friendly patterns const users = await collection.find({ email: 'john@example.com' }).toArray();
Recommendation
Add concrete templates for schema design patterns (one-to-one, one-to-many, many-to-many) with specific document structures
13 / 15

Progress:

  • Schema Design: Plan document structure and relationships
  • Indexing Strategy: Create appropriate indexes before data growth
  • Query Implementation: Write efficient queries using aggregation pipeline
  • Performance Testing: Monitor query performance and optimize
  • Error Handling: Implement proper connection and operation error handling

Schema Design Process

  1. Identify access patterns and query requirements
  2. Design embedded vs referenced data based on read/write patterns
  3. Plan for data growth and sharding if needed
  4. Validate schema with sample data

Query Optimization

  1. Use explain() to analyze query execution
  2. Create compound indexes for multi-field queries
  3. Use aggregation pipeline for complex data transformations
  4. Implement proper pagination with cursor-based approach
Recommendation
Include performance monitoring examples with specific metrics and thresholds (e.g., query execution time > 100ms)
18 / 20

Example 1: User Profile with Embedded Data Input: User with posts and comments

JavaScript
// Schema design { _id: ObjectId, username: "johndoe", profile: { firstName: "John", lastName: "Doe", avatar: "avatar.jpg" }, recentPosts: [ { title: "Post 1", createdAt: ISODate, excerpt: "..." } ] } // Efficient query db.users.find({ username: "johndoe" }).project({ "recentPosts": { $slice: 5 } })

Example 2: Aggregation Pipeline Input: Calculate user engagement metrics

JavaScript
db.users.aggregate([ { $match: { lastLogin: { $gte: new Date(Date.now() - 30*24*60*60*1000) } } }, { $lookup: { from: "posts", localField: "_id", foreignField: "authorId", as: "posts" } }, { $project: { username: 1, postCount: { $size: "$posts" }, avgLikes: { $avg: "$posts.likes" } }}, { $sort: { postCount: -1 } } ])

Example 3: Proper Indexing

JavaScript
// Compound index for common query patterns db.users.createIndex({ "status": 1, "createdAt": -1 }) db.posts.createIndex({ "authorId": 1, "publishedAt": -1 }) // Text index for search db.posts.createIndex({ "title": "text", "content": "text" })
Recommendation
Provide connection configuration templates for different environments (development, staging, production) with appropriate settings
  • Always use connection pooling in production environments
  • Create indexes before inserting large datasets to avoid performance issues
  • Use projection to limit returned fields and reduce network traffic
  • Implement proper error handling with retry logic for transient failures
  • Use transactions for multi-document operations that need consistency
  • Validate data at application level before database operations
  • Monitor slow queries using MongoDB profiler and explain plans
  • Use appropriate read/write concerns based on consistency requirements
  • Don't create indexes on every field - they slow down writes and consume space
  • Avoid large arrays (>100 elements) in frequently updated documents
  • Don't use regex queries without proper indexes (causes collection scans)
  • Never store sensitive data without encryption
  • Don't ignore connection limits - always close connections properly
  • Avoid deeply nested documents (MongoDB limit is 100 levels)
  • Don't use findAndModify for bulk operations - use bulk operations instead
  • Never perform joins in application code - use $lookup aggregation stage
0
Grade BAI Skill Framework
Scorecard
Criteria Breakdown
Quick Start
15/15
Workflow
13/15
Examples
18/20
Completeness
2/20
Format
15/15
Conciseness
12/15