2.Access the mongo Shell Help-官方文档摘录
2017-07-19 09:08
645 查看
总结:
1.使用help可以查看帮助信息db.help() help等
2.查看对应的实现方法.比如
3 查看封装好的类的方法可以使用help xxx,比如BinData()这个方法,在misc类中,则help misc
In addition to the documentation in the MongoDB Manual, the
To see the list of databases on the server, use the
New in version 2.4:
To see the list of help for methods you can use on the
To see the implementation of a method in the shell, type the
To see the list of collections in the current database, use the
To see the help for methods available on the collection objects (e.g.
To see the collection method implementation, type the
To list the available modifier and cursor handling methods, use the
To see the implementation of the cursor method, type the
Some useful methods for handling cursors are:
For examples on iterating a cursor and retrieving the documents from the cursor, see cursor handling. See also Cursor for all available cursor methods.
SEE ALSO
mongo Shell Methods
1.使用help可以查看帮助信息db.help() help等
2.查看对应的实现方法.比如
test@gzxkvm52$ db.updateUser function (name, updateObject, writeConcern) { var cmdObj = {updateUser: name}; cmdObj = Object.extend(cmdObj, updateObject); cmdObj['writeConcern'] = writeConcern ? writeConcern : _defaultWriteConcern; this._modifyCommandToDigestPasswordIfNecessary(cmdObj, name); var res = this.runCommand(cmdObj); if (res.ok) { return; } if (res.errmsg == "no such cmd: updateUser") { this._updateUserV1(name, updateObject, cmdObj['writeConcern']); return; } throw _getErrorWithCode(res, "Updating user failed: " + res.errmsg); }
3 查看封装好的类的方法可以使用help xxx,比如BinData()这个方法,在misc类中,则help misc
test@gzxkvm52> 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 "hexstr" string, sequence of hex characters (no 0x prefix) 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) d = ISODate() like Date() but behaves more intuitively when used d = ISODate('YYYY-MM-DD hh:mm:ss') without an explicit "new " prefix on construction
In addition to the documentation in the MongoDB Manual, the
mongoshell provides some additional information in its “online” help system. This document provides an overview of accessing this help information.
Command Line Help
To see the list of options and help for starting themongoshell, use the
--helpoption from the command line:
mongo --help
Shell Help
To see the list of help, in themongoshell, type
help:
help
Database Help
In themongoshell:
To see the list of databases on the server, use the
show dbscommand:
show dbs
New in version 2.4:
show databasesis now an alias for
show dbs
To see the list of help for methods you can use on the
dbobject, call the
db.help()method:
db.help()
To see the implementation of a method in the shell, type the
db.<method name>without the parenthesis (
()), as in the following example which will return the implementation of the method
db.updateUser():
db.updateUser
Collection Help
In themongoshell:
To see the list of collections in the current database, use the
show collectionscommand:
show collections
To see the help for methods available on the collection objects (e.g.
db.<collection>), use the
db.<collection>.help()method:
db.collection.help()
<collection>can be the name of a collection that exists, although you may specify a collection that doesn’t exist.
To see the collection method implementation, type the
db.<collection>.<method>name without the parenthesis (
()), as in the following example which will return the implementation of the
save()method:
db.collection.save
Cursor Help
When you perform read operations with thefind()method in the
mongoshell, you can use various cursor methods to modify the
find()behavior and various JavaScript methods to handle the cursor returned from the
find()method.
To list the available modifier and cursor handling methods, use the
db.collection.find().help()command:
db.collection.find().help()
<collection>can be the name of a collection that exists, although you may specify a collection that doesn’t exist.
To see the implementation of the cursor method, type the
db.<collection>.find().<method>name without the parenthesis (
()), as in the following example which will return the implementation of the
toArray()method:
db.collection.find().toArray
Some useful methods for handling cursors are:
hasNext()which checks whether the cursor has more documents to return.
next()which returns the next document and advances the cursor position forward by one.
forEach(<function>)which iterates the whole cursor and applies the
<function>to each document returned by the cursor. The
<function>expects a single argument which corresponds to the document from each iteration.
For examples on iterating a cursor and retrieving the documents from the cursor, see cursor handling. See also Cursor for all available cursor methods.
Wrapper Object Help
To get a list of the wrapper classes available in themongoshell, such as
BinData(), type
help miscin the
mongoshell:
help misc
SEE ALSO
mongo Shell Methods
相关文章推荐
- 14.Iterate a Cursor in the mongo Shell-官方文档摘录
- 3.Write Scripts for the mongo Shell-官方文档摘录
- 4.Data Types in the mongo Shell-官方文档摘录
- 1.Configure the mongo Shell-官方文档摘录
- MongoDB - The mongo Shell, Access the mongo Shell Help
- Cocos Creator 生命周期回调(官方文档摘录)
- CritterAI官方文档翻译【Compiling the Input】
- android官方文档:ubuntu10.04下编译android源码Building the System
- Processing Bitmaps Off the UI Thread不在UI线程中处理Bitmaps(Android官方翻译文档2)
- Cocos Creator 加载和切换场景(官方文档摘录)
- 简读The Swift Programming Language官方文档--下标脚本 Subscripts
- WebSocket官方文档翻译——HTML5 Web Sockets:A Quantum Leap in Scalability for the Web
- mongo官方文档阅读笔记---mongo的限制
- Cocos Creator中模块化脚本(官方文档摘录)
- Influxdb-官方文档摘录
- ICE官方文档中2.2【The Ice Architecture】章节翻译之一
- CritterAI官方文档翻译【The Incremental Builder】
- Mongo官方文档翻译 (一)
- Android官方文档翻译 七 2.Adding the Action Bar
- 制作freebsd U盘启动过程。官方文档摘录