Mongodb基礎操作實踐- -Mongodb Shell端

來源:互聯網
上載者:User

標籤:tags   sed   test   data   gray   process   localhost   sse   local   

一、串連

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端

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.