![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
mongodb
kong-kong
记录流水账
展开
-
$unwind
$unwind db.inventory.insert( { "_id":"1","item":"ABC1",sizes:[ "S", "M", "L"] } ) db.inventory.aggregate( [ { $unwind : "$sizes" } ] ) ----------------------------------------------...翻译 2019-11-13 09:52:49 · 559 阅读 · 0 评论 -
aggregate
# 统计orders集合数量 db.orders.aggregate( [ { $group: { _id: null, count: { $sum: 1 } } }, { $project: { _id: 0 } } ] ) db.articles.insertMany([ { _id: ObjectId("12769ea0f3dc6ead47c9a1b...翻译 2019-11-11 19:14:18 · 1109 阅读 · 0 评论 -
map-reduce demo
db.orders.insertMany([ { _id: ObjectId("10a8240b927d5d8b5891743c"), cust_id: "1", ord_date: new Date("Oct 04, 2012"), status: 'A', price: 25, items: [ { sku: "mmm", ...翻译 2019-11-11 15:09:14 · 290 阅读 · 0 评论 -
map-reduce
db.inventory.insertMany([ { item: "journal", qty: 25, size: { h: 14, w: 21, uom: "cm" }, status: "A" }, { item: "journal", qty: 50, size: { h: 8.5, w: 11, uom: "in" }, status: "A" }, { it...翻译 2019-11-11 09:21:43 · 254 阅读 · 0 评论 -
Bulk Write Operations
db.collection.bulkWrite(). db.characters.bulkWrite( [ { insertOne : { "document" : { "_id" : 4, "char" : "Dithras", "class"...翻译 2019-11-07 17:44:46 · 343 阅读 · 0 评论 -
Update Documents
主要方法 db.collection.updateOne(<filter>,<update>,<options>) db.collection.updateMany(<filter>,<update>,<options>) db.collection.replaceOne(<filter>,<...翻译 2019-11-07 09:27:57 · 516 阅读 · 0 评论 -
Configuration File Options
默认配置文件 On Linux, a default/etc/mongod.confconfiguration file is included when using a package manager to install MongoDB. On Windows, a default<installdirectory>/bin/mongod.cfgconfigurati...翻译 2019-11-06 16:30:01 · 280 阅读 · 0 评论 -
Delete Documents
db.collection.drop() # 删除集合 # 还删除与删除的集合关联的所有索引 db.collection.drop() # mongo在执行删除操作时不会删除相应的索引 # 即使删除某个collection中的所有数据 # 方法 db.collection.deleteMany() db.collection.deleteOne() 准备数据 db.in...翻译 2019-11-06 10:51:00 · 292 阅读 · 0 评论 -
Query Documents
插入多条数据 db.inventory.insertMany([ { item: "journal", qty: 25, size: { h: 14, w: 21, uom: "cm" }, status: "A" }, { item: "notebook", qty: 50, size: { h: 8.5, w: 11, uom: "in" }, status: "A" ...翻译 2019-11-06 10:43:35 · 257 阅读 · 0 评论 -
Insert Documents
_idField In MongoDB, each document stored in a collection requires a unique_idfield that acts as aprimary key. If an inserted document omits the_idfield, the MongoDB driver automatically gen...翻译 2019-11-06 10:21:52 · 416 阅读 · 0 评论 -
mongo命令
# 默认端口是27017 mongo # 指定端口 mongo --port 28015 # 连接远程主机 mongo "mongodb://mongodb0.example.com:28015" mongo --host mongodb0.example.com:28015 mongo --host mongodb0.example.com --port 28015 # 指定连接...翻译 2019-11-06 09:51:44 · 229 阅读 · 0 评论 -
mongodb install
1. 创建/etc/yum.repos.d/mongodb-org-4.2.repo文件 文件内容 [mongodb-org-4.2] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/ gpgcheck=1 enabled=1 g...翻译 2019-11-06 09:32:36 · 282 阅读 · 0 评论