Lightweight MongoDB ODM with Zod validation
TypeScript-first ODM built on the native MongoDB driver. Define schemas with Zod, get automatic id conversion, timestamps, pagination, and relation lookups — in ~300 lines.
npm install @mauroandre/zodmongoA focused ODM that handles schemas, queries, relations, and pagination — so you can skip the boilerplate.
Define your models with Zod. Types are inferred automatically. No proprietary schema format, no decorators.
Built directly on the official MongoDB driver. No Mongoose overhead, no hidden abstractions. Just fast, direct access.
Full type inference from your Zod schemas. Autocomplete for queries, documents, and pagination — everywhere.
Declare references between collections. The ODM generates $lookup pipelines automatically from your schema.
Paginated queries via $facet in a single aggregation call. Page metadata included — no extra count query.
Work with id (string) in your app, _id (ObjectId) in MongoDB. Bidirectional conversion is automatic and recursive.