当前位置:网站首页>Some basic uses of mongodb
Some basic uses of mongodb
2022-06-26 00:13:00 【Daily log of the great demon king】
establish MongoDB Containers
docker run di --name=tianxingwen_mongodb -p 27017:27017 mongo
Remote login
mongo 192.168.53.132
Create database
use spitdb
Add, delete, change and look up the grammar
Inquire about
grammar :
db. Collection name .find()
db.spit.find()
according to id Query a piece of data
db.spit.find({"_id":“1”})
db.spit.findOne({"_id":“1”})
Query the first few data
db.spit.find().limit(3)
newly added
insert data
grammar :
db. Collection name .insert( data );
db.spit.insert({content:“ It's so cold ”,visits:10})
modify
grammar :
db. Collection name .update( Conditions , Revised data )
db.spit.update({_id:“1”},{visits:NumberInt(1000)})
Note that after the above command is executed id by 1 All other fields of the will be deleted automatically
terms of settlement :
db.spit.update({_id:“2”},{$set:{visits:NumberInt(2000)}})
Delete
grammar :
db. Collection name .remove( Conditions )
Delete all
db.spit.remove({})
Delete... According to conditions Delete visits:1000 This data of
db.spit.remove({visits:1000})
Statistics
Statistics of all
db.spit.count()
Statistics according to specified conditions
db.spit.count({userid:“1013”})
Fuzzy query
Inquire about content Field contains java All documents of
db.spit.find({content:/java/})
Inquire about content With java At the beginning
db.spit.find({content:/^java/})
Greater than less than
grammar :
db. Collection name .find({ “field” : { $gt: value }}) // Greater than : field > value db. Collection name .find({ “field” : { $lt: value }}) // Less than : field < value db. Collection name .find({ “field” : { $gte: value }}) // Greater than or equal to : field >= value
db. Collection name .find({ “field” : { $lte: value }}) // Less than or equal to : field <= value
db. Collection name .find({ “field” : { $ne: value }}) // It's not equal to : field != value
Inquire about id>1 The data of
db.spit.find({"_id":{$gt:“1”}})
Inclusion and exclusion
Inquire about userid Field contains 1013,1014 Documents
db.spit.find({userid:{$in:[“1013”,“1014”]}})
Inquire about userid Field does not contain 1013,1014 Documents
db.spit.find({userid:{$nin:[“1013”,“1014”]}})
Conditional connection
Grammar format
$and:[ { },{ },{ } ]
Query collection visits Greater than or equal to 1000 And less than 2000 The article of
db.spit.find({ KaTeX parse error: Expected '}', got 'EOF' at end of input: and:[ {visits:{ gte:1000}} ,{visits:{$lt:2000} }]})
If the relationship between two or more conditions is or , We use Operators , With the front and Use The same way
KaTeX parse error: Expected '}', got 'EOF' at end of input: …*db.spit.find({ or:[ {userid:“1013”} ,{visits:{$lt:2000} }]})
Secondary title
Increase or decrease the value of a column on the basis of the original value , have access to KaTeX parse error: Expected '}', got 'EOF' at end of input: …ate({_id:"2"},{ inc:{visits:NumberInt(1)}} )**
边栏推荐
- Mysql5.7 is in the configuration file my Ini[mysqld] cannot be started after adding skip grant tables
- redis之集群
- 11.1.1、flink概述_flink概述
- 迅为RK3568开发板使用RKNN-Toolkit-lite2运行测试程序
- 解决线程并发安全问题
- 贴片机供料器(feeder)飞达的种类,如何工作
- Building cloud computers with FRP
- Reading notes on how to connect the network - hubs, routers and routers (III)
- Prototype chain test questions in JS --foo and getname
- Transformation of communication protocol between Siemens S7-200PLC and Danfoss inverter_ Old bear passing by_ Sina blog
猜你喜欢

EBS R12.2.0升级到R12.2.6

Explain in detail the three types of local variables, global variables and static variables

什么是微服务
![[wechat official account H5] generates a QR code with parameters to enter the official account attention page to listen to user-defined menu bar for official account events (server)](/img/d9/935bad29005e5846dc514c966e3b0e.png)
[wechat official account H5] generates a QR code with parameters to enter the official account attention page to listen to user-defined menu bar for official account events (server)

(Reprint) visual explanation of processes and threads

DNS review

Hand made pl-2303hx USB to TTL level serial port circuit_ Old bear passing by_ Sina blog

Studio5k V28 installation and cracking_ Old bear passing by_ Sina blog

How ASA configures port mapping and pat

迅为RK3568开发板使用RKNN-Toolkit-lite2运行测试程序
随机推荐
Redis cluster
Lazy people teach you to use kiwi fruit to lose 16 kg in a month_ Old bear passing by_ Sina blog
Shredding Company poj 1416
redux工作流程+小例子的完整代码
ValueError: color kwarg must have one color per data set. 9 data sets and 1 colors were provided
Recommended system design
SMT葡萄球现象解决办法
14.1.1、Promethues监控,四种数据类型metrics,Pushgateway
Redis之常见问题
11.1.2、flink概述_Wordcount案例
Bit compressor [Blue Bridge Cup training]
Simulation connection between WinCC and STEP7_ Old bear passing by_ Sina blog
dhcp复习
Using swiper to realize the rotation chart
DNS复习
文献调研(二):基于短期能源预测的建筑节能性能定量评估
huibian
10.2.2、Kylin_kylin的安装,上传解压,验证环境变量,启动,访问
About Simple Data Visualization
tensorrt pb转uff问题