MongoDB
Document modeling, aggregations, and indexing for production MongoDB.
MongoDB is the database I reach for when the data model is naturally hierarchical or evolves quickly — AI document metadata, NFC analytics events, multi-tenant configs. I design schemas with read patterns in mind, use indexes deliberately, and lean on the aggregation framework rather than pulling data into the app to crunch it.
How I work with MongoDB
MongoDB has been my main NoSQL store across most of my Node.js and NestJS projects. I started with Mongoose schemas and progressed to native-driver usage when I needed full control over queries or bulk operations.
Schema design is where I spend the most time up front — denormalizing for read patterns, embedding when growth is bounded, referencing when it is not. I have learned the hard way that 'just throw it all in a document' becomes a bottleneck when access patterns evolve.
I rely heavily on the aggregation pipeline for reporting, analytics rollups, and joins between collections. I use compound indexes to make those pipelines fast and verify with `.explain()` rather than guessing.
MongoDB across business domains
Stored document metadata, processing-job status, and extracted structured data — with aggregations driving the analytics dashboard.
Captured per-tap analytics events and built rollup aggregations for daily/weekly dashboards.
Modeled listings with embedded media + denormalized agent info for fast list/detail reads.
Backed the inventory catalog with MongoDB; used aggregations to power dealer-level dashboards.
Real issues I resolved using MongoDB
Turned a 9-second analytics page into a 400ms page
An NFC analytics dashboard was scanning a 50M-document events collection on every load, with no supporting indexes.
Designed a compound index keyed on `(tenantId, eventDate, profileId)`, rewrote the aggregation to use $match early, and added a pre-computed daily rollup collection refreshed by a scheduled job.
Dashboard load time dropped from ~9s to ~400ms, primary cluster CPU normalized, and the rollups made future reports trivial to add.
Fixed unbounded array growth that was breaking documents
An audit-log array was embedded inside a tenant document; some tenants hit the 16MB document size limit after months of activity.
Migrated audit logs to a separate collection with a reference to tenant id and a TTL index for retention. Backfilled in batches with bulk writes during off-peak hours.
Eliminated document-size errors entirely, brought storage growth under control, and made audit queries faster thanks to a focused index.
Stopped a runaway find() from melting the primary
An ad-hoc admin query without an index was running an unindexed collection scan, blocking reads and pushing replica lag.
Added the missing compound index, set `maxTimeMS` on all admin queries, and locked unindexed queries out of production via a code-review checklist + `.explain()` in dev.
Replica lag returned to baseline, no more incident pages from admin queries, and devs got faster feedback when they were about to ship something expensive.
Often used together
Have a MongoDB project in mind?
I am open to full-time and contract work where MongoDBis core to the stack. Let's talk about what you are building.