欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

6.mongo命令提示符幫助-創(chuàng)新互聯(lián)

6.mongo命令提示符幫助

最新內(nèi)容會(huì)在源站更新.轉(zhuǎn)載請(qǐng)保留原文鏈接: http://dashidan.com/article/mongodb/index.html

定陶ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)公司的ssl證書銷售渠道,可以享受市場價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!

① mongo命令行參數(shù)幫助

通過--help參數(shù)顯示命令行幫助信息

mongo --help

顯示:

MongoDB shell version: 2.0.4usage: mongo [options] [db address] [file names (ending in .js)]db address can be:   foo                   foo database on local machine  192.169.0.5/foo       foo database on 192.168.0.5 machine  192.169.0.5:9999/foo  foo database on 192.168.0.5 machine on port 9999options:   --shell               run the shell after executing files  --nodb                don't connect to mongod on startup - no 'db address'                         arg expected   --norc                開始不執(zhí)行".mongorc.js"文件   --quiet               安靜模式   --port arg            端口   --host arg            IP   --eval arg            運(yùn)行javascript腳本   -u [ --username ] arg 用戶名   -p [ --password ] arg 密碼   -h [ --help ]         顯示這個(gè)幫助信息   --version             版本號(hào)   --verbose             increase verbosity   --ipv6                開啟IPv6支持(默認(rèn)關(guān)閉)

② mongo指令幫助

通過命令提示符連上mongo數(shù)據(jù)庫后,可以輸入help來顯示命令提示符幫助.

help

會(huì)顯示:

db.help()                    數(shù)據(jù)庫方法幫助信息db.mycoll.help()             集合方法幫助信息rs.help()                    help on replica set methods help admin                   管理員幫助信息help connect                 連接數(shù)據(jù)庫幫助help keys                    快捷鍵help misc                    雜項(xiàng)信息幫助help mr                      mapreduce幫助show dbs                     顯示全部數(shù)據(jù)庫名show collections             顯示當(dāng)前數(shù)據(jù)庫中的全部集合名show users                   顯示當(dāng)前數(shù)據(jù)庫的全部用戶show profile                 show most recent system.profile entries with time >= 1msshow logs                    顯示可以連接的日志(`logger`)名show log [name]              輸出內(nèi)存中的最近log的片段, 默認(rèn)輸出`global`use <db_name>                設(shè)定當(dāng)前數(shù)據(jù)庫db.foo.find()                顯示集合`foo`中的對(duì)象列表db.foo.find( { a : 1 } )     查詢foo集合中`a == 1`的對(duì)象it                           輸入it, 繼續(xù)迭代顯示結(jié)果, 輸出更多結(jié)果DBQuery.shellBatchSize = x   設(shè)置顯示結(jié)果條數(shù)exit                         退出命令行

③ 數(shù)據(jù)庫幫助

1.顯示全部數(shù)據(jù)庫

show dbs

2.顯示部數(shù)據(jù)操作幫助

db.help()

3.顯示方法的實(shí)現(xiàn)

顯示一個(gè)數(shù)據(jù)的方法的具體實(shí)現(xiàn),輸入db.<method name>不帶(). 例如:

db.updateUser

顯示:

test.updateUser

④ 集合幫助

1.顯示全部集合

show collections

2.顯示集合幫助

db.collection.help()

顯示

db.collection.find().help() - show DBCursor help db.collection.count()db.collection.dataSize()db.collection.distinct( key ) - eg. db.collection.distinct( 'x' )db.collection.drop() drop the collection db.collection.dropIndex(name)db.collection.dropIndexes()db.collection.ensureIndex(keypattern[,options]) - options is an object with these possible fields: name, unique, dropDups db.collection.reIndex()db.collection.find([query],[fields]) - query is an optional query filter. fields is optional set of fields to return.                                               e.g. db.collection.find( {x:77} , {name:1, x:1} )db.collection.find(...).count()db.collection.find(...).limit(n)db.collection.find(...).skip(n)db.collection.find(...).sort(...)db.collection.findOne([query])db.collection.findAndModify( { update : ... , remove : bool [, query: {}, sort: {}, 'new': false] } )db.collection.getDB() get DB object associated with collection db.collection.getIndexes()db.collection.group( { key : ..., initial: ..., reduce : ...[, cond: ...] } )db.collection.mapReduce( mapFunction , reduceFunction , <optional params> )db.collection.remove(query)db.collection.renameCollection( newName , <dropTarget> ) renames the collection.db.collection.runCommand( name , <options> ) runs a db command with the given name where the first param is the collection name db.collection.save(obj)db.collection.stats()db.collection.storageSize() - includes free space allocated to this collection db.collection.totalIndexSize() - size in bytes of all the indexes db.collection.totalSize() - storage allocated for all data and indexes db.collection.update(query, object[, upsert_bool, multi_bool])db.collection.validate( <full> ) - SLOW db.collection.getShardVersion() - only for use with sharding db.collection.getShardDistribution() - prints statistics about data distribution in the cluster

3.顯示集合方法實(shí)現(xiàn)

顯示方法實(shí)現(xiàn)輸入db.<collection>.<method>, 不帶(). 例如輸入:

db.collection.save

顯示:

function (obj) {     if (obj == null || typeof obj == "undefined") {         throw "can't save a null";     }     if (typeof obj == "number" || typeof obj == "string") {         throw "can't save a number or string";     }     if (typeof obj._id == "undefined") {         obj._id = new ObjectId;         return this.insert(obj);     } else {         return this.update({_id:obj._id}, obj, true);     }}

⑤ cursor幫助

當(dāng)你在mongo命令行使用find()方法時(shí), 可以使用很多cursor方法來修改find()行為和結(jié)果.

  • 顯示find()方法可用的修改器和cursor處理方法

    db.collection.find().help()

顯示:

> db.collection.find().help()find() modifiers    .sort( {...} )     .limit( n )     .skip( n )     .count() - total # of objects matching query, ignores skip,limit     .size() - total # of objects cursor would return, honors skip,limit     .explain([verbose])     .hint(...)     .showDiskLoc() - adds a $diskLoc field to each returned objectCursor methods    .forEach( func )     .map( func )     .hasNext()     .next()
  • cursor方法的實(shí)現(xiàn), 輸入db.<collection>.find().<method>, 不包含(). 例如:

db.collection.find().toArray

顯示:

> db.collection.find().toArrayfunction () {     if (this._arr) {         return this._arr;     }     var a = [];     while (this.hasNext()) {         a.push(this.next());     }     this._arr = a;     return a;}

常用的cursor方法

  • hasNext() 查詢cursor是否還有數(shù)據(jù).

  • next() 返回下一個(gè)數(shù)據(jù)對(duì)象, 并且cursor指向位置加1.

  • forEach(

    ) 方法遍歷執(zhí)行全部結(jié)果. 只有1參數(shù), 迭代器中指向的對(duì)象.

⑥ 包裝對(duì)象幫助

可以通過輸入help misc來獲取對(duì)象包裝類.

help misc

顯示:

> help misc     b = new BinData(subtype,base64str)  create a BSON BinData value     b.subtype()                         the BinData subtype (0..255)     b.length()                          length of the BinData data in bytes     b.hex()                             the data as a hex encoded string     b.base64()                          the data as a base 64 encoded string     b.toString()     b = HexData(subtype,hexstr)         create a BSON BinData value from a hex string     b = UUID(hexstr)                    create a BSON BinData value of UUID subtype     b = MD5(hexstr)                     create a BSON BinData value of MD5 subtype     o = new ObjectId()                  create a new ObjectId     o.getTimestamp()                    return timestamp derived from first 32 bits of the OID     o.isObjectId()     o.toString()     o.equals(otherid)

⑦ 參考文章

 官方文檔

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

分享名稱:6.mongo命令提示符幫助-創(chuàng)新互聯(lián)
本文來源:http://www.chinadenli.net/article12/cchcdc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供Google軟件開發(fā)網(wǎng)站排名品牌網(wǎng)站制作網(wǎng)站內(nèi)鏈商城網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站建設(shè)