MongoDB CRUD Operations

CRUD operations create, read, update, and deletedocuments.

Create Operations

Create or insert operations add new documents to a collection. If thecollection does not currently exist, insert operations will create thecollection.

MongoDB provides the following methods to insert documents into acollection:

In MongoDB, insert operations target a single collection. Allwrite operations in MongoDB are atomic on the level of a singledocument.

The components of a MongoDB insertOne operations.

For examples, see Insert Documents.

Read Operations

Read operations retrieves documents from acollection; i.e. queries a collection fordocuments. MongoDB provides the following methods to read documents froma collection:

You can specify query filters or criteria that identify the documents to return.

The components of a MongoDB find operation.

For examples, see:

Update Operations

Update operations modify existing documents in a collection. MongoDBprovides the following methods to update documents of a collection:

In MongoDB, update operations target a single collection. All writeoperations in MongoDB are atomic on the level of a single document.

You can specify criteria, or filters, that identify the documents toupdate. These filters use the samesyntax as read operations.

The components of a MongoDB updateMany operation.

For examples, see Update Documents.

Delete Operations

Delete operations remove documents from a collection. MongoDB providesthe following methods to delete documents of a collection:

In MongoDB, delete operations target a single collection. Allwrite operations in MongoDB are atomic on the level of a single document.

You can specify criteria, or filters, that identify the documents toremove. These filters use the samesyntax as read operations.

The components of a MongoDB deleteMany operation.

For examples, see Delete Documents.

Bulk Write

MongoDB provides the ability to perform write operations in bulk. Fordetails, see Bulk Write Operations.