当前位置:Gxlcms > 数据库问题 > MongoDB - MongoDB CRUD Operations

MongoDB - MongoDB CRUD Operations

时间:2021-07-01 10:21:17 帮助过:14人阅读

. All write operations in MongoDB are atomic on the level of a single document.

技术分享

For examples, see Insert Documents.

 

Read Operations

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

  • db.collection.find()

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

技术分享

For examples, see Query Documents.

 

Update Operations

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

  • db.collection.update()
  • db.collection.updateOne() New in version 3.2
  • db.collection.updateMany() New in version 3.2
  • db.collection.replaceOne() New in version 3.2

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

You can specify criteria, or filters, that identify the documents to update. These filters use the same syntax as read operations.

技术分享

For examples, see Update Documents.

 

Delete Operations

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

  • db.collection.remove()
  • db.collection.deleteOne() New in version 3.2
  • db.collection.deleteMany() New in version 3.2

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

You can specify criteria, or filters, that identify the documents to remove. These filters use the same syntax as read operations.

技术分享

For examples, see Delete Documents.

 

Bulk Write

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

 

MongoDB - MongoDB CRUD Operations

标签:documents   evel   get   mat   ref   nts   oss   nal   https   

人气教程排行