
mongodb
kong-kong
记录流水账
展开
-
$unwind
$unwinddb.inventory.insert( { "_id":"1","item":"ABC1",sizes:[ "S", "M", "L"] })db.inventory.aggregate( [ { $unwind : "$sizes" } ] )----------------------------------------------...翻译 2019-11-13 09:52:49 · 609 阅读 · 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 · 1144 阅读 · 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 · 314 阅读 · 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 · 274 阅读 · 0 评论 -
Bulk Write Operations
db.collection.bulkWrite().db.characters.bulkWrite( [ { insertOne : { "document" : { "_id" : 4, "char" : "Dithras", "class"...翻译 2019-11-07 17:44:46 · 372 阅读 · 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 · 552 阅读 · 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 · 306 阅读 · 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 · 322 阅读 · 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 · 279 阅读 · 0 评论 -
Insert Documents
_idFieldIn 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 · 442 阅读 · 0 评论 -
mongo命令
# 默认端口是27017mongo# 指定端口mongo --port 28015# 连接远程主机mongo "mongodb://mongodb0.example.com:28015"mongo --host mongodb0.example.com:28015mongo --host mongodb0.example.com --port 28015# 指定连接...翻译 2019-11-06 09:51:44 · 252 阅读 · 0 评论 -
mongodb install
1. 创建/etc/yum.repos.d/mongodb-org-4.2.repo文件文件内容[mongodb-org-4.2]name=MongoDB Repositorybaseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/gpgcheck=1enabled=1g...翻译 2019-11-06 09:32:36 · 309 阅读 · 0 评论