首页 > 数据库技术 > 详细

Mongodb基础操作实践- -Mongodb Shell端

时间:2017-07-09 12:10:31      阅读:309      评论:0      收藏:0      [点我收藏+]

一、连接

1.mongo mongodb://localhost:27000

2.

show databases(dbs)

use test

3.

db

show collections

二、插入

1.db.proccessedfile.insertone({fileName:"20170403/3.gz", processedDate:new ISODate(), dataNumber:10000, x:10})

2.db.mongodb.insertMany([    { item: "journal", qty: 25, tags: ["blank", "red"], size: { h: 14, w: 21, uom: "cm" } },    { item: "mat", qty: 85, tags: ["gray"], size: { h: 27.9, w: 35.5, uom: "cm" } },    { item: "mousepad", qty: 25, tags:["gel", "blue"], size: { h: 19, w: 22.85, uom: "cm" } } ])

三、查询

1.

db.proccessedfile.find()

db.proccessedfile.find().pretty()//pretty格式化,document或bson.document,类json标准格式输出,基于查询均可追加上

2.db.mongodb.find( { item: "mousepad" } )

3.db.mongodb.find( { qty: {$in: [25, 29]} } ).pretty()//=,后接数组数据的集合,类似or操作,$or后接数组集合的集合

4.

db.mongodb.find( {qty: {$lte: 85}} ).pretty()//>=

db.mongodb.find( {qty: {$lte: 85, $gte: 25 }} ).pretty()//>=, <=

db.mongodb.find( {item: "mousepad", qty: {$lte: 85, $gte: 25 }} ).pretty()//and操作

Mongodb基础操作实践- -Mongodb Shell端

原文:http://www.cnblogs.com/tangyongathuse/p/7140699.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!