All Challenges
1 PointBasic
00:00

MongoDB: In-Memory Query Matcher & Aggregation Pipeline Filter

Build an in-memory document query engine supporting $eq, $gt, $in, $regex, $and, $or, and $project/$sort pipeline stages.

### Problem Overview In MongoDB interviews, understanding how queries and aggregation filters evaluate documents under the hood is critical. You must build an In-Memory MongoDB Query Matcher & Pipeline Engine in TypeScript that evaluates complex filter expressions against JSON document collections, resolves nested dot-notation paths, and executes core aggregation stages ($match, $project, $sort, and $limit). ### Functional Requirements 1. **Query Operators Evaluation**: - Comparison: `$eq`, `$ne`, `$gt`, `$gte`, `$lt`, `$lte`. - Inclusions: `$in`, `$nin`. - Pattern: `$regex`. - Logical: `$and`, `$or`, `$nor`. 2. **Nested Dot-Notation Path Resolution**: - Querying `"user.profile.age": { "$gte": 18 }` must resolve properties deeply into nested sub-documents. 3. **Aggregation Pipeline Method (`aggregate(pipeline)`)**: - `$match`, `$project`, `$sort`, and `$limit`.
AI Review Rubric Dimensions (1–10 Points):
  • Nested path resolution
  • Operator logic ($gt, $in, $regex)
  • Logical operators ($and, $or)
  • Aggregation stage sequencing
solution.tsTYPESCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
20 lines•444 characters•
AI Review Ready