【MongoDB】The basic operation of Mongodb, Insert\Query\Delete\Update
来源:互联网 发布:美国监狱黑帮 知乎 编辑:程序博客网 时间:2024/06/01 08:29
1, Insert
MongoDB is database storing document object, the type of which is called Bson.(like JSON);
Example: // document defination
Now after using command[db.posts.insert(doc)], you will insert record successfully if seeing the
The following picture.
2. Query
One of the fundamental functions of MongoDB is to support query dynamically, which is the same as the troditional relational database, but more effiecieny than that.
2.1 Query Expression Ojbects:
Query expression objects document is also a bson-structure document. For example, we could use the following the command to find all the record in the collections:
2.2 Query Item
In addition to Query expression object, Mongodb still support extra argument items. For example, you may only wanna return some certain fields. For example:
Example 1: return all the fields expect for tags;
Example 2: return dall fields expect for comments and tags=”albert”
Example 3: return the only field ’name’ and gender=’male’
3. Remove
Removing operation is used to remove records from the collections.Example:
Advice: It’s better to use _id as condition when executing the remove operation/
Attention: In some conditions, when you are ready to remove one record, maybe in the meantime the update operation is updating this record which makes the reomve operation failed. As for this case, you could add the $atomic field to avoid this case. For example:
4. Update
4.1 Grammar
Argument Description:
Criteria: the object used to set query conditions
Objnew: Object used to set update content.
Upsert: if record exists, it will update it. Else insert a new record.
Multi: if multi matches conditoin, it will update all the records.
Attention: By fault, mongoDB will update the first record that matches the query condition.
- 【MongoDB】The basic operation of Mongodb, Insert\Query\Delete\Update
- 【MonogoDB】The high update operation of MongoDB
- 【MongoDB】The high Query operation of MongoDB(一)
- 【MongoDB】The high query operation of MongoDB(二)
- 【MongoDB】The high query operation of MongoDB(三)
- 【MongoDB】The basic operation of Index in MongoDB
- 【MongoDB】The basic operation of Index in MongoDB
- 【MongoDB】The Regex Expression query of MongoDB
- 數據庫訪問類(Query,Insert,Update,Delete)
- SQL Basic Statement(INSERT/DELETE/UPDATE/SELECT)
- Basic ReplicaSet Deployment of MongoDB
- The tail of MongoDB
- the basic operation of sequence in python
- android query insert update delete的参数意义
- SQLiteDatabase中query、insert、update、delete方法参数说明
- SQLiteDatabase中query、insert、update、delete方法参数说明
- SQLiteDatabase中query、insert、update、delete方法参数说明
- SQLiteDatabase中query、insert、update、delete方法参数说明
- Android 自定义View,自定义属性--自定义圆形进度条(整理)
- 用Gradle 构建你的android程序
- day26,page50,total150
- N-Queens
- 跳出内联框架
- 【MongoDB】The basic operation of Mongodb, Insert\Query\Delete\Update
- 浮点数
- 自动装箱与自动拆箱
- hdu-1078 FatMouse and Cheese(记忆化搜索)
- How to avoid uppercase function name while using Function in latex?
- STM32的时钟简介和配置方法
- Java保留两位小数 and 浮点数精确计算 and BigDecimal介绍
- [Android]通过PhoneLookup读取所有电话号码
- x86-64模式