Here's how you can implement soft delete with Mongoose.
The Most Popular Database Framework for Node.js
Mongoose is the most downloaded database framework for Node.js. MongoDB is the natural choice for Node.js applications, and Mongoose helps you build fast, production-ready applications with Node.js and MongoDB.
Mastering Mongoose is the complete guide to building and maintaining Mongoose applications, written by Mongoose's long-time maintainer. Get the eBook today!
Mongoose Tutorials
Here's how you can use limit() to return a fixed number of documents with Mongoose `find()`.
Here's what the "Buffering timed out after 10000ms" error means in Mongoose, and how to fix it.
Mongoose models don't have an `insertOne()` function, but `create()` is similar. Here's what you need to know.
Here's two ways that Mongoose lets you execute code when a document is deleted: using middleware, and using change streams.
Here's how you can use enum validators in Mongoose.
Here's how you can restrict Mongoose's `find()` function to only return certain fields using `select()`.
Running into "Query was already executed" errors in Mongoose? Here's what causes this error, and how to fix it.
Mongoose doesn't have a `deleteById()` function, but here's how you can delete an object by its _id 👉
Mongoose models have an `deleteMany()` function that allows deleting all documents that match a filter. Here's what you need to know.
Mongoose models have an `updateMany()` function that allows updating all documents that match a filter. Here's what you need to know.
By default, Mongoose's `findOneAndUpdate()` function returns the document as it was before the update was applied. Here's how you can change that 👉
Here's what you need to know about `findOneAndUpdate()` in Mongoose.
Need to run a query in Mongoose using query string parameters? Here's what you need to know 👉
Here's how you can validate emails, and ensure emails are unique, using Mongoose.
Mongoose's `find()` function works with async/await. Here's how you can use async/await with Mongoose queries.
Mongoose connections have a `db` property that lets you bypass Mongoose and talk to MongoDB directly. Here's what you need to know.
How to use connect() and createConnection() in an async function.
Mongoose connections have a `readyState` property that lets you check if Mongoose is connected to MongoDB. Here's what you need to know.
Mongoose has a built-in timestamps option that sets `createdAt` and `updatedAt` on your documents automatically. Here's how you can use it.
Mongoose's `create()` function is a convenience wrapper around `save()`. Here's what you need to know.
Mongoose lets you define schema paths as `unique`, but the `unique` option has a few important caveats. Here's what you need to know.
MongoDB does not have a LIKE operator akin to SQL, but MongoDB does support queries by regular expressions. Here's how you can use regexp queries to simulate SQL's LIKE operator in Mongoose.
Mongoose queries have an `explain()` helper that let you inspect what indexes a query used. Here's how you can use `explain()` to figure out how a query performed.
Mongoose's `save()` function persists the changes you made to a document to the database. Here's what you need to know.
Mongoose arrays supports arrays of primitives and arrays of subdocuments. Here's how you can work with Mongoose arrays effectively.
In Mongoose, a SchemaType is a configuration object for a given path within a schema. Here's what you need to know.
Aggregations in Mongoose let you perform complex transformations on your data in MongoDB. Here's what you need to know.
Everything you need to know about the `mongoose.Promise` property.
Mongoose populate lets you store references to other collections and load referenced documents with one line. Here's what you need to know.
In MongoDB, every document's `_id` property is an ObjectId by default. Here's what you need to know about ObjectIds in Mongoose.
In Mongoose, schemas are a configuration object for models. They tell Mongoose what paths to cast/validate, what options to set, and what virtuals to create.
The `mongoose.connect()` function is the most common way to connect to MongoDB with Mongoose. This tutorial describes how to use `mongoose.connect()` and how to troubleshoot common issues.
A tutorial about how to use the `findById()` function in Mongoose.
The Mongoose `Model.find()` function finds all documents in a collection that match a query. In this tutorial, you will learn how to structure common queries in Mongoose.
An overview of the Mongoose Query class and how to use it to query for documents
A tutorial about how to get all documents in a Mongoose model
Learn how to use insert a document in Mongoose if it doesn't already exist
Learn about declaring and using virtuals in Mongoose.
Learn about the different ways to update a document in Mongoose.
Learn how to understand and debug E11000 errors in Mongoose.