Mongoose Documentation
The official docs for Mongoose, the most widely used MongoDB object modelling library for Node.js: schemas, validation, middleware, populate, discriminators, transactions and TypeScript support. Read the guides, not just the quick start, because most Mongoose bugs come from misunderstood defaults.
27.5k (Automattic/mongoose)
GitHub · Sept 2026
9.10.2 (September 2026)
GitHub · Sept 2026
7.6M (week to 26 Sept 2026)
npm · Sept 2026
MIT
GitHub · Sept 2026
Guide
Web Development
Mongoose (Automattic)
An afternoon for the quick start, a week for the guides
Intermediate
Free
What Mongoose is
Mongoose is an object data modelling (ODM) library for MongoDB and Node.js. You describe each collection with a schema, compile it into a model, and work with documents as objects that validate themselves, run middleware and cast values to the right types. It is built on the official Node.js driver. The documentation site covers the current 9.x line, with docs for 8.x, 7.x and 6.x still available from the version menu.
Is it worth learning?
If you are building an Express or NestJS style backend on MongoDB, very likely yes: it is the library most Node.js MongoDB tutorials, courses and existing codebases use, including the MongoDB part of the University of Helsinki's Full Stack Open course. Schemas and validation also give a flexible database the guard rails beginners usually need.
It is not compulsory. Mongoose adds a layer with its own behaviour, and some teams prefer the plain driver with TypeScript types. Knowing both is the strongest position.
The guides worth reading
The quick start (the famous kittens example) takes ten minutes. The real value is in the guides:
- Schemas and SchemaTypes: types, defaults,
required,enum, custom getters and setters, and schema options such astimestamps. - Validation: built-in and custom validators, and the important detail that update queries do not run validators unless you ask them to.
- Middleware: pre and post hooks, and which hooks fire for
saveversusupdateOne. - Populate: Mongoose's way of following references between collections. Convenient, but every populate is at least one extra query, so it is not a free join.
- Subdocuments and discriminators: embedding, and storing several related shapes in one collection.
- Queries and lean:
.lean()returns plain objects and is much cheaper for read-heavy endpoints. - Transactions and TypeScript: both have dedicated pages.
Prerequisites
JavaScript with async/await, basic MongoDB queries, and ideally a feel for the Node.js driver underneath. The npm metadata for the current release requires Node.js 20.19.0 or later.
Common mistakes the docs help you avoid
- Designing schemas like SQL tables and populating everything, instead of embedding what is read together.
- Assuming
findOneAndUpdateruns validation andsavemiddleware. - Forgetting to create indexes in production, or relying on automatic index builds on large collections.
- Returning full Mongoose documents from hot endpoints instead of lean objects.
Common questions
Is Mongoose an ORM? It is usually called an ODM, since MongoDB stores documents rather than relational rows.
Is it free? Yes, it is open source under the MIT licence.
What can I do after it? Model a real application's data with validated schemas, relationships, hooks and transactions, and know when to drop down to the driver.
Best for: Node.js developers building APIs on MongoDB who want structure without giving up the document model.
Ready to start?
Opens on Mongoose (Automattic) in a new tab.
Stuck on something specific?
Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.
Follow along
New writing, resources and project ideas land here first.