MongoDB - The mongo Shell, Access the mongo Shell Help
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了MongoDB - The mongo Shell, Access the mongo Shell Help,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3211字,纯文字阅读大概需要5分钟。
内容图文
![MongoDB - The mongo Shell, Access the mongo Shell Help](/upload/InfoBanner/zyjiaocheng/473/452a408c8a9344bf964d6b76572dad66.jpg)
Command Line Help
To see the list of options and help for starting the mongo shell, use the --help option from the command line:
mongo --help
Shell Help
To see the list of help, in the mongo shell, type help:
help
Database Help
In the mongo shell:
- To see the list of databases on the server, use the show dbs command:
show dbs
New in version 2.4: show databases is now an alias for show dbs
- To see the list of help for methods you can use on the db object, 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 the mongo shell:
- To see the list of collections in the current database, use the show collections command:
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 the find() method in the mongo shell, 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 the mongo shell, such as BinData(), type help misc in the mongo shell:
help misc
MongoDB - The mongo Shell, Access the mongo Shell Help
标签:res when save bind osi info find inf tar
本文系统来源:http://www.cnblogs.com/huey/p/6120288.html
内容总结
以上是互联网集市为您收集整理的MongoDB - The mongo Shell, Access the mongo Shell Help全部内容,希望文章能够帮你解决MongoDB - The mongo Shell, Access the mongo Shell Help所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。