5.MongoDB CRUD Operations-官方文档摘录
2017-07-25 10:03
726 查看
总结1. CRUD:create, read, update, and delete DOCUMENT2.在3.2版本的插入方式
db.users.insertOne(
{
name:"sue",
age:26,
status:"pending"}
)
db.users.find( { age:{$gt:18}, name:1,address:1 } )5 Delete操作
db.collection.insertOne() db.collection.insertMany()
db.users.insertOne(
{
name:"sue",
age:26,
status:"pending"}
)
3 Read 操作
db.users.find( { age:{$gt:18}, name:1,address:1 } )4 Update操作
db.collection.updateOne() db.collection.updatMany() db.collection.replaceOne()
db.users.find( { age:{$gt:18}, name:1,address:1 } )5 Delete操作
db.users.deleteOne() db.users.deleteMany()CRUD operations create, read, update, and delete documents.
Create Operations
Create or insert operations add new documents to a collection. If the collection does not currently exist, insert operations will create the collection.MongoDB provides the following methods to insert documents into a collection:db.collection.insertOne()New in version 3.2
db.collection.insertMany()New in version 3.2In MongoDB, insert operations target a single collection. 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 DocumentsQuery on Embedded/Nested DocumentsQuery an ArrayQuery an Array of Embedded Documents
Update Operations
Update operations modify existing documents in a collection. MongoDB provides the following methods to update documents of a collection:db.collection.updateOne()New in version 3.2
db.collection.updateMany()New in version 3.2
db.collection.replaceOne()New in version 3.2In 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.deleteOne()New in version 3.2
db.collection.deleteMany()New in version 3.2In 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.相关文章推荐
- Influxdb-官方文档摘录
- Influxdb-官方文档摘录
- Cocos Creator 生命周期回调(官方文档摘录)
- Cocos Creator系统内置事件和玩家输入事件(官方文档摘录)
- Influxdb-官方文档摘录
- Influxdb-官方文档摘录
- 2.Access the mongo Shell Help-官方文档摘录
- Cocos Creator 加载和切换场景(官方文档摘录)
- Cocos Creator中使用动作系统(官方文档摘录)
- Cocos Creator中使用动作列表(官方文档摘录)
- Influxdb-官方文档摘录
- Influxdb-官方文档摘录
- 20.Bulk Write Operations-官方文档摘录
- Influxdb-官方文档摘录
- Influxdb-官方文档摘录
- 摘录ECMAScript官方文档中重要的两段话
- Cocos Creator中使用计时器(官方文档摘录)
- Influxdb-官方文档摘录
- Influxdb-官方文档摘录
- InnoDB官方文档摘录1