-
TS + Mongoose version is in this repo
-
Discussed in Medium article(s)
- ✅ drop mongoose dependency
- ✅ mongo client setup
- ✅ schema design via zod
- ✅ actually validate with ZOD
- ✅ index on reviews
- ✅ extract service logic from route handlers
- ✅ change schema design: bootcamp references populated persistently, other references are looked up
- ✅ replicate mongoose middleware (calculations) with mongo adaptor
- ✅ replicate mongoose lookups with mongo adaptor
- ✅ update seeder to accomodate new schema
- ✅ advanced search with mongo adaptor: aggregation pipeline incl. advanced filtering
CONSTRAINTS -- user owner of bootcamp is the only one who can add a course to that bootcamp -- -- max 1 bootcamp per owner --
Only bootcamps references are persisted as subdocuments. The others are looked up on the fly when requested.
BOOTCAMP
- owner: ref
- courses: ref[]
- participants: ref[]
USER
- bootcampOwned: subDoc
- bootcampsJoined: subDoc[]
REVIEW
- bootcamp: subDoc
- author: ref
COURSE
- bootcamp: subDoc
- owner: ref
-
Missing Error Handling (always assuming db CRUD ops succeed)
-
No atomicity in operations (basic CRUD + hook-equivalents should occur together atomically)
-
Advanced search
- not properly validating queryParams -> suboptimal error handling
- agg pipeline stages for advanced filtering uses hardcoded fields (identify fields that are arrays)
- casting of queryParams to numbers where necessary -> identified based on hardcoded fields