ZodMongo

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.

Get started in seconds

npm install @mauroandre/zodmongo

Everything you need

A focused ODM that handles schemas, queries, relations, and pagination — so you can skip the boilerplate.

Zod-Native Schemas

Define your models with Zod. Types are inferred automatically. No proprietary schema format, no decorators.

Native MongoDB Driver

Built directly on the official MongoDB driver. No Mongoose overhead, no hidden abstractions. Just fast, direct access.

TypeScript-First

Full type inference from your Zod schemas. Autocomplete for queries, documents, and pagination — everywhere.

Relations & Lookups

Declare references between collections. The ODM generates $lookup pipelines automatically from your schema.

Built-in Pagination

Paginated queries via $facet in a single aggregation call. Page metadata included — no extra count query.

Transparent id/ObjectId

Work with id (string) in your app, _id (ObjectId) in MongoDB. Bidirectional conversion is automatic and recursive.