当前位置:网站首页>Mongodb/ document operation
Mongodb/ document operation
2022-07-05 20:17:00 【Why not sell egg cakes well】
06 Inserted into the document
Insert multiple
db.stus.insert({ object 2},{ object 3});
Will be generated according to the timestamp id
You can also define
Import the development environment data into the production environment
Data may be duplicated Add to each document id attribute , Make sure it's unique .
7 Query the document
db.status.find({
_id:"hello"});
Query all eligible documents ;
db.stus.find({
age:16,name:"xians"});
There are many ways of conditional transmission .
;
db.collection.findOne(); // Query the first eligible document
find() It returns an array ;
db.collection.find({
}).count();// Query the number of all results
8 Modify the document
db.stus.update({name:" The sand monk "},{age:33});
Partial modification
db.stus.update(
{
"_id":ObjectId("hsfhkdh")},
{
$set:{
name:" Pig eight quit ",
address:" Liusha River "
}}
)
$unset
db.stus.update(
{"_id":ObjectId("hsfhkdh")},
{$unset:{
name:" Pig eight quit "
}}
)
db.collection.updateMany() // Modify multiple qualified documents at the same time .
db.collection.updateOne() // Modify a qualified document
update // Only one is changed by default
modify update The default attribute of can be modified at the same time
db.stus.update(
{"name":" solve "}
{$set:{
name:" Pig eight quit "
}},
{multi:true}
)
9 Delete the document
remove Delete multiple by default , Delete only one , You need to set the parameter to true;
db.stus.remove({_id:"hello"},true);
// If you pass an empty parameter , Delete all
// Empty the set , Slightly poor performance . First match , And then delete . It is more convenient to delete the set directly
db.stus.remove({});
Delete the collection
db.stus.drop();
Generally, database data will not be deleted , Just add a parameter , To indicate whether the data has been deleted ,.
db.updateOne({name="ts"},{$set:{idDel:1}});
db.stus.find({idDel:0})
边栏推荐
- - Oui. Net Distributed Transaction and Landing Solution
- Go language | 01 wsl+vscode environment construction pit avoidance Guide
- Elk distributed log analysis system deployment (Huawei cloud)
- kubernetes资源对象介绍及常用命令(五)-(ConfigMap&Secret)
- After 95, Alibaba P7 published the payroll: it's really fragrant to make up this
- 淺淺的談一下ThreadLocalInsecureRandom
- 关于BRAM IP复位的优先级
- 期货如何网上开户?安不安全?
- Debezium series: idea integrates lexical and grammatical analysis ANTLR, and check the DDL, DML and other statements supported by debezium
- USACO3.4 “破锣摇滚”乐队 Raucous Rockers - DP
猜你喜欢
[quick start of Digital IC Verification] 3. Introduction to the whole process of Digital IC Design
After 95, Alibaba P7 published the payroll: it's really fragrant to make up this
Go language | 02 for loop and the use of common functions
How to select the Block Editor? Impression notes verse, notation, flowus
2023年深圳市绿色低碳产业扶持计划申报指南
[quick start to digital IC Verification] 8. Typical circuits in digital ICs and their corresponding Verilog description methods
Leetcode brush questions: binary tree 11 (balanced binary tree)
Scala基础【HelloWorld代码解析,变量和标识符】
leetcode刷题:二叉树18(最大二叉树)
Station B up builds the world's first pure red stone neural network, pornographic detection based on deep learning action recognition, Chen Tianqi's course progress of machine science compilation MLC,
随机推荐
Jvmrandom cannot set seeds | problem tracing | source code tracing
A way to calculate LNX
图嵌入Graph embedding学习笔记
Scala基础【HelloWorld代码解析,变量和标识符】
实操演示:产研团队如何高效构建需求工作流?
Leetcode skimming: binary tree 16 (path sum)
CTF reverse Foundation
js实现禁止网页缩放(Ctrl+鼠标、+、-缩放有效亲测)
Codeforces Round #804 (Div. 2) - A, B, C
信息学奥赛一本通 1337:【例3-2】单词查找树 | 洛谷 P5755 [NOI2000] 单词查找树
Unity编辑器扩展 UI控件篇
c语言oj得pe,ACM入门之OJ~
14. Users, groups, and permissions (14)
淺淺的談一下ThreadLocalInsecureRandom
leetcode刷题:二叉树12(二叉树的所有路径)
【c语言】归并排序
什么是pyc文件
sort和投影
2020 CCPC 威海 - A. Golden Spirit(思维),D. ABC Conjecture(大数分解 / 思维)
基础篇——配置文件解析