# Prisma ORM vs Mongoose: contract file or schema in application code? (/compare/mongoose) > Prisma ORM vs Mongoose: contract file or schema in application code? For the complete Prisma website index, see [llms.txt](https://www.prisma.io/llms.txt). A Markdown version of any listed page is available at its `.md` URL — this one is `/compare/mongoose.md`. Checked October 2026. dateModified: 2026-10-19 Prisma ORM 8 types MongoDB queries, aggregations, and migrations from a contract file. Mongoose models documents in application code. Checked October 2026. Both give you typed MongoDB access in TypeScript, from opposite ends. [Prisma ORM](/docs/orm) starts from a contract file: you describe your collections once, and typed queries, aggregations, and migrations follow from it. [Mongoose](https://mongoosejs.com) starts from a Schema in application code: you compile it with `mongoose.model` and query with `find()` and `populate()`. [Get started with Prisma ORM](/docs/prisma-orm/quickstart/postgresql) [Create an instant database](https://create-db.prisma.io/web) By [Martin Janse van Rensburg](/blog/author/martin-janse-van-rensburg) · Updated October 2026 · 12 min read[X](https://x.com/vanrensbird)[LinkedIn](https://www.linkedin.com/in/martjvr/)[GitHub](https://github.com/vanrensbird) Prisma makes Prisma ORM\. Mongoose figures come from the pages listed under [Sources](/compare/mongoose#sources), checked October 2026\. ## When should I choose Mongoose or Prisma ORM? | Mongoose | Prisma ORM | | --- | --- | | You want the schema next to the model in application code, compiled with `mongoose.model`. | You want models in a contract file, `contract.prisma` — a contract is the file that describes your collections or tables. | | You want `populate()` to replace a stored id with a document from another collection. | You want `contract emit` to write the query types. Prisma ORM 8 does not use the `@prisma/client` package. That package is Prisma ORM 7. | | You want pre and post hooks on documents, queries, aggregates, and models. | You want a typed aggregation pipeline, polymorphic collections from `@@discriminator`, and `migration plan` to write `migration.ts` for indexes and JSON Schema validators. `db migrate` runs `ops.json`. | | The database is MongoDB, and `find()` should take MongoDB query operators. | You also ship on PostgreSQL, where the release candidate includes the ORM client, a SQL query builder, and relation filters. | MongoDB's May 2026 post [Prisma Next: The TypeScript ODM You Always Wanted](https://www.mongodb.com/company/blog/technical/prisma-next-typescript-odm-you-always-wanted) is their write-up of this work: typed documents, a typed aggregation pipeline, and migrations for indexes instead of a deploy script. On prisma.io the same library is Prisma ORM 8's MongoDB early access, not a separate product named Prisma Next. ## What does the same query look like in each? Each snippet reads published posts with their authors: Mongoose attaches the authors with `populate("author")`, and Prisma ORM loads them with `include("author")`. The MongoDB tab is representative of the commands both send, not captured from a live run. **Mongoose** ```ts import { Post } from "./models/post"; const posts = await Post.find({ published: true }) .populate("author"); ``` **Prisma ORM** ```ts import { db } from "./src/prisma/db"; const posts = await db.orm.posts .where({ published: true }) .include("author") .all(); ``` **MongoDB sent** ```ts // Representative commands matching both snippets above, not captured from a live run. // Mongoose populate: a find, then a second find for the authors db.posts.find({ published: true }) db.users.find({ _id: { $in: [...] } }) // Prisma ORM include: the same two-query pattern db.posts.find({ published: true }) db.users.find({ _id: { $in: [...] } }) ``` author includepublished filterTinted lines match across the open tab. Hover one to emphasize its pair. ## How do Prisma ORM and Mongoose compare feature by feature? Mongoose models MongoDB documents in application code. Prisma ORM is a contract-based ORM with a typed pipeline, polymorphic collections, and MongoDB migrations for indexes and validators. On MongoDB the PostgreSQL APIs (SQL query builder, relation filters) are absent. Columns are in alphabetical order. | Feature | Mongoose | Prisma ORM | | --- | --- | --- | | Library price | Free. MIT license. | Free. Apache License 2.0. | | Release status | Version 9.11.2 on npm. Mongoose 9.0.0 shipped on 21 November 2025. The getting started guide is this 9.x line. | Prisma ORM 8 is a release candidate, and it is what `npm install prisma` gives you. The final release is still to come. PostgreSQL is the release-candidate database. MongoDB is early access. | | Data model | A Schema and a Model in application code. `mongoose.model` compiles the schema. | A contract file, `contract.prisma`. On MongoDB you write that file yourself: `contract infer` does not read a MongoDB database. `contract emit` writes the types. There is no `@prisma/client` package. | | Queries | `Model.find()` and the other query helpers, with MongoDB query operators. | An ORM client, `db.orm.`, addressed by the storage name (`db.orm.posts`, not `db.orm.Post`\). A pipeline builder for aggregation, and raw commands for anything the two APIs do not cover. | | Embedded documents | Nested schemas and subdocuments on the parent document. | A `type` block in the contract, used as a field. Embedded values have no `_id` and no collection of their own. | | Polymorphic collections | `Model.discriminator()` stores variants in one collection. Variant fields are optional or split across schemas you keep in application code. | `@@discriminator` on the base model and `@@base` on each variant. `db.orm.posts.variant('article')` narrows the TypeScript type. Query all posts and you get the union. | | Aggregation | `Model.aggregate()` takes a pipeline array. Stages are not type-checked. | The pipeline builder at `db.query` types field names and each stage's output. Raw commands cover stages the builder does not. | | Related documents | `populate()` loads related documents in a separate query. `match` filters which of those documents are attached, and the parent stays in the result. `populate()` cannot filter parents by a field on the related document. | On MongoDB, `include()` loads a reference declared with `@relation`, and it takes the relation name only. An array of ids stored on the parent has no `include()` equivalent yet; the migrate guide uses `lookup` in the pipeline builder. Relation filters are not available on MongoDB. On PostgreSQL, `where` can use `some`, `none`, and `every`. | | Middleware | pre and post hooks. Four kinds: document, model, aggregate, and query middleware. | Middleware runs on MongoDB, except `beforeCompile`, which exists on PostgreSQL. The cache middleware runs on both databases. | | Migrations | The getting started guide has no migration command. | `migration plan` writes `migration.ts` from the contract. Planning does not connect to a database. `db migrate` runs `ops.json`. On MongoDB that file can create collections, indexes, and JSON Schema validators, and it can run a `dataTransform`. | | Databases | MongoDB. The README describes Mongoose as a MongoDB object modeling tool. | PostgreSQL is a release candidate. MongoDB is early access. SQLite is experimental. MySQL, MariaDB, SQL Server, and CockroachDB stay on Prisma ORM 7. See [database support](/compare/mongoose#databases). | | Hosted database | None. Mongoose is a library. You bring MongoDB. | [Prisma Postgres](/docs/postgres) is a separate product. Any Postgres client works with it, so Prisma ORM is optional. Mongoose connects to MongoDB, so it does not connect to Prisma Postgres. [Prisma Compute](/docs/compute) is separate app hosting. | ## Which databases do Prisma ORM and Mongoose support? Mongoose's MongoDB support next to the two Prisma ORM lines. Prisma ORM 7 is the generally available release. No means no support. The [MongoDB product page](/mongodb) describes Prisma's schema and type-safe client for MongoDB, including embedded documents and references. Its query samples use Prisma Client's `findMany` API from earlier Prisma ORM lines. Prisma ORM 8 queries go through `db.orm.`. | Database | Mongoose | Prisma ORM 8 | Prisma ORM 7 | | --- | --- | --- | --- | | MongoDB | Supported | Early access | Use 6.19 | | PostgreSQL | No | Release candidate | Supported | | MySQL | No | ORM 7 only | Supported | | MariaDB | No | ORM 7 only | Supported | | Microsoft SQL Server | No | ORM 7 only | Supported | | SQLite | No | Experimental | Supported | | CockroachDB | No | ORM 7 only | Supported | MongoDB on Prisma ORM 7 is listed as supported on the ORM 7 databases page. The ORM 7 [migrate-from-Mongoose guide](/docs/guides/v7/switch-to-prisma-orm/from-mongoose) says Prisma ORM 7 has no MongoDB connector yet, and to stay on 6.19 until it ships. This table follows that guide for MongoDB. Sources: [Mongoose README](https://github.com/Automattic/mongoose/blob/master/README.md), [Prisma ORM 8 supported databases](/docs/orm/supported-databases), and [Prisma ORM 7 supported databases](/docs/orm/v7/reference/supported-databases), October 2026\. ## What does Prisma ORM do that Mongoose doesn't? ### A typed aggregation pipeline Mongoose's `aggregate()` takes a pipeline array. Prisma ORM 8's MongoDB library has a pipeline builder that types field names and the shape after each stage, then you drop to raw commands when the builder does not cover a stage. [MongoDB without compromise](/blog/mongodb-without-compromise) is the Prisma write-up of that stack, checked against the [pipeline builder](/docs/orm/reference/pipeline-builder). ### Polymorphic collections from the contract `@@discriminator` and `@@base` declare variants in one collection, and `.variant('article')` narrows the TypeScript union. Mongoose has [`discriminator()`](https://mongoosejs.com/docs/discriminators.html) too; the Prisma side generates the unions from the contract. MongoDB's [Prisma Next post](https://www.mongodb.com/company/blog/technical/prisma-next-typescript-odm-you-always-wanted) says their Driver team named this as the top missing feature in earlier Prisma ORM. The [MongoDB data modeling](/docs/orm/data-modeling/mongodb) docs are the current syntax. ### Migrations for indexes and validators `migration plan` writes `migration.ts` without connecting to the database. On MongoDB, `db migrate` can create collections, indexes, and JSON Schema validators, and it can run a `dataTransform`. The April 2026 [MongoDB without compromise](/blog/mongodb-without-compromise) post said data migrations were still coming; the [migration API](/docs/orm/reference/migration-api) now documents `dataTransform` on MongoDB. ### The same ORM client on PostgreSQL Mongoose speaks MongoDB. Prisma ORM 8's PostgreSQL library is a release candidate: the ORM client, a SQL query builder, and relation filters (`some`, `none`, `every`\) that the MongoDB client does not have. ## How much do Prisma ORM and Mongoose cost? | Cost | Mongoose | Prisma ORM | | --- | --- | --- | | Library license and cost | Free, MIT | Free, Apache 2.0 | | Paid plans | None | None for the ORM | | Hosted database | None. You bring MongoDB. | [Prisma Postgres](/docs/postgres), optional. It is PostgreSQL, so Mongoose does not connect to it. | Prisma Postgres has a Free plan: $0 a month for 200,000 operations, 2 GB of storage, and 50 databases. The [pricing page](/pricing) lists the paid plans. ## When is Prisma ORM the wrong choice? - You want document and query middleware, and `populate()` on arrays of stored ids, from a MongoDB library that is already a stable release. Prisma ORM 8's MongoDB library is early access. An array of ids has no `include()` equivalent yet. See [migrate from Mongoose](/docs/guides/switch-to-prisma-orm/from-mongoose). - You want multi-document transactions on MongoDB. `db.transaction()` is absent on the MongoDB client. Multi-document writes go through the MongoDB driver. See [supported databases](/docs/orm/supported-databases). - You need MySQL, MariaDB, SQL Server, or CockroachDB from the current Prisma ORM 8 packages. Those databases are absent from ORM 8. [Prisma ORM 7](/docs/orm/v7) still supports them. Mongoose speaks MongoDB. See [supported databases](/docs/orm/supported-databases). ## How does each task look in Mongoose and Prisma ORM? What each step of the usual workflow looks like on each side, for a team moving in either direction. | Task | Mongoose | Prisma ORM | | --- | --- | --- | | Define collections | A `Schema` compiled with `mongoose.model`. | Models in `contract.prisma`, with `@@map` for the collection name. | | Generate types | TypeScript types you write, or types inferred from the schema in application code. | `contract emit` writes the types from the contract. | | Read an existing database | The schemas in the app are the source of truth. MongoDB has no schema to infer. | `contract infer` does not read MongoDB. You write `contract.prisma` from the Mongoose schemas. | | Write a migration | The getting started guide has no migration command. You change documents in code. | `migration plan` writes `migration.ts`. On MongoDB that can include `createIndex`, `setValidation`, and `dataTransform`. | | Run an aggregation | `Model.aggregate([...])` with untyped pipeline stages. | `db.query.from('')`, then `runtime.query(...)` or `runtime.execute(...)`. | | Query a polymorphic collection | `Model.discriminator()` and query the discriminator model. | `@@discriminator` / `@@base` in the contract, then `.variant('article')` on the base collection. | | Load a related document | `populate()` on a stored id. `match` can narrow which related documents come back. | `include()` on a single `@relation`. An array of ids has no `include()` equivalent yet; use `lookup` in the pipeline builder. | | Run middleware | pre and post hooks on documents, queries, aggregates, and models. | Middleware on MongoDB, except `beforeCompile`. The cache middleware runs on MongoDB. | | Apply schema changes | You update documents yourself. There is no Mongoose migrate command in the guide. | `db migrate` applies the pending migrations on disk. | ## How do I switch from Mongoose to Prisma ORM? The [migrate-from-Mongoose guide](/docs/guides/switch-to-prisma-orm/from-mongoose) adds Prisma ORM beside the collections you already have. `orm init --target mongodb` writes the Prisma files. `contract infer` does not read a MongoDB database, so you write `contract.prisma` from the Mongoose schemas, then `contract emit` writes the types. The documents stay where they are. Representative models for the User and Post collections in the query above, then the two commands. **Mongoose schema** ```ts import { Schema, model } from "mongoose"; const userSchema = new Schema({ email: { type: String, required: true, unique: true }, name: { type: String }, }); export const User = model("User", userSchema); const postSchema = new Schema({ title: { type: String, required: true }, published: { type: Boolean, default: false }, author: { type: Schema.Types.ObjectId, ref: "User", required: true }, }); export const Post = model("Post", postSchema); ``` **contract.prisma** ```prisma // use prisma-8 model User { id ObjectId @id @map("_id") email String @unique name String? posts Post[] @@map("users") } model Post { id ObjectId @id @map("_id") title String published Bool author User @relation(fields: [authorId], references: [id]) authorId ObjectId @map("author") @@map("posts") } ``` ```bash npx prisma@latest orm init --target mongodb npx prisma contract emit ``` 1. Later changes go through [contract emit and migration plan](/docs/orm/migrations/generating-a-migration). On MongoDB you still write the contract by hand. ## How do I switch from Prisma ORM to Mongoose? 1. Keep the MongoDB database and the connection string. 2. Define a `Schema` and compile it with `mongoose.model` for each collection. The [getting started guide](https://mongoosejs.com/docs/) is that path. 3. Use `populate()` on stored ids. Prisma ORM's `include()` on MongoDB covers a single `@relation`; an array of ids uses `lookup` in the pipeline builder. ## What do teams say about Prisma ORM? Two teams on what type safety in Prisma ORM does for them. > “Prisma makes database management incredibly easy. Prisma's built-in type safety helps us avoid mistakes that happen with manual setups.” Ron Cohen, Co-founder & CTO, Bucket > “We chose Prisma because it provides us with type safety directly from the database. It has helped us tremendously to catch possible errors early on.” Omar López, Sr. Software Engineer, Cal.com ## Frequently asked questions ### Is Prisma Next a different product from Prisma ORM 8? No. MongoDB's May 2026 post [Prisma Next: The TypeScript ODM You Always Wanted](https://www.mongodb.com/company/blog/technical/prisma-next-typescript-odm-you-always-wanted) uses that name for the TypeScript ODM built with Prisma. On prisma.io the same work is Prisma ORM 8's MongoDB library, `@prisma/orm-mongo`, which is early access. `npm install prisma` installs Prisma ORM 8. The post's `npx prisma-next init` command is not the current install path; the docs use `npx prisma@latest orm init --target mongodb`. Source: that MongoDB post, [MongoDB without compromise](/blog/mongodb-without-compromise), and [supported databases](/docs/orm/supported-databases), October 2026. ### Does Prisma ORM work with MongoDB? Yes. The [MongoDB product page](/mongodb) describes Prisma's schema and a type-safe client for MongoDB, including filters, pagination, ordering, embedded documents, and references. Its query samples use Prisma Client's `findMany` API from earlier Prisma ORM lines. Prisma ORM 8 queries go through `db.orm.`. MongoDB on Prisma ORM 8 is early access: the ORM client, pipeline builder, and migrations work; `db.transaction()` does not. Source: [MongoDB product page](/mongodb), [supported databases](/docs/orm/supported-databases), October 2026. ### Can Prisma ORM and Mongoose use the same MongoDB database? Yes. The migrate guide adds Prisma ORM beside Mongoose and reads the same collections. You write `contract.prisma` for the collections you query through Prisma ORM. `contract infer` does not read MongoDB. The documents stay where they are. Source: [migrate from Mongoose](/docs/guides/switch-to-prisma-orm/from-mongoose), October 2026. ### Does Mongoose work with Prisma Postgres? Mongoose connects to MongoDB. Prisma Postgres is PostgreSQL, and Prisma ORM is optional with it: a Postgres client uses the connection string. Mongoose is not a Postgres client. Source: [Mongoose getting started](https://mongoosejs.com/docs/) and [Prisma Postgres](/docs/postgres), October 2026. ## Add Prisma ORM to an existing project Prisma ORM is free and open source, and always will be. - Add the library - Read the ORM docs - Trusted by 500K+ developers globally Need a database? [Create an instant database](https://create-db.prisma.io/web). [Get started with Prisma ORM](/docs/prisma-orm/quickstart/postgresql) [Get started with Prisma Postgres](https://console.prisma.io) ## Sources Every competitor figure on this page comes from these pages, checked October 2026\. ### Mongoose - [Getting started](https://mongoosejs.com/docs/) - [mongoose on npm](https://www.npmjs.com/package/mongoose) - [Populate](https://mongoosejs.com/docs/populate.html) - [Discriminators](https://mongoosejs.com/docs/discriminators.html) - [Middleware](https://mongoosejs.com/docs/middleware.html) - [README](https://github.com/Automattic/mongoose/blob/master/README.md) - [MIT license](https://github.com/Automattic/mongoose/blob/master/LICENSE.md) ### Prisma ORM and Prisma Postgres - [Prisma ORM docs](/docs/orm) - [Supported databases](/docs/orm/supported-databases) - [Prisma ORM 7 supported databases](/docs/orm/v7/reference/supported-databases) - [Migrate from Mongoose](/docs/guides/switch-to-prisma-orm/from-mongoose) - [Prisma ORM 7 migrate from Mongoose](/docs/guides/v7/switch-to-prisma-orm/from-mongoose) - [contract emit](/docs/cli/contract-emit) - [migration plan](/docs/cli/migration-plan) - [db migrate](/docs/cli/db-migrate) - [Apache License 2.0](https://github.com/prisma/prisma/blob/main/LICENSE) - [Prisma Postgres pricing](/pricing) - [Prisma + MongoDB](/mongodb) - [MongoDB without compromise](/blog/mongodb-without-compromise) - [Prisma Next: The TypeScript ODM You Always Wanted](https://www.mongodb.com/company/blog/technical/prisma-next-typescript-odm-you-always-wanted)