2.Access the mongo Shell Help-官方文档摘录
总结:
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 mongo shell 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 the mongo shell, use the --help option from the command line:
mongo --help
Database Help
In the mongo shell:
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 forshow dbsTo see the list of help for methods you can use on the
dbobject, call thedb.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 methoddb.updateUser():db.updateUser
Collection Help
In the mongo shell:
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 thedb.<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 thesave()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 thetoArray()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 themongo shell:
help misc
SEE ALSO
2.Access the mongo Shell Help-官方文档摘录的更多相关文章
- Cocos Creator 加载和切换场景(官方文档摘录)
Cocos Creator 加载和切换场景(官方文档摘录) 在 Cocos Creator 中,我们使用场景文件名( 可以不包含扩展名)来索引指代场景.并通过以下接口进行加载和切换操作: cc.dir ...
- ng的概念层次(官方文档摘录)
官方文档是这么说的: You write Angular applications by: composing HTML templates with Angularized markup, writ ...
- Cocos Creator 生命周期回调(官方文档摘录)
Cocos Creator 为组件脚本提供了生命周期的回调函数.用户通过定义特定的函数回调在特定的时期编写相关 脚本.目前提供给用户的声明周期回调函数有: onLoad start update la ...
- Cocos Creator 使用计时器(官方文档摘录)
在 Cocos Creator 中,我们为组件提供了方便的计时器,这个计时器源自于 Cocos2d-x 中的 cc.Scheduler,我们将它保留在了 Cocos Creator 中并适配了基于组件 ...
- angular 模板语法(官方文档摘录)
https://angular.cn/guide/template-syntax {{}} 和"" 如果嵌套,{{}}里面求完值,""就是原意 <h3&g ...
- Spring Cloud官方文档中文版-Spring Cloud Config(上)
官方文档地址为:http://cloud.spring.io/spring-cloud-static/Dalston.SR2/#spring-cloud-feign 文中例子我做了一些测试在:http ...
- Spring Data Commons 官方文档学习
Spring Data Commons 官方文档学习 -by LarryZeal Version 1.12.6.Release, 2017-07-27 为知笔记版本在这里,带格式. Table o ...
- 【翻译】Django Channels 官方文档 -- Tutorial
Django Channels 官方文档 https://channels.readthedocs.io/en/latest/index.html 前言: 最近课程设计需要用到 WebSocket,而 ...
- hbase官方文档(转)
FROM:http://www.just4e.com/hbase.html Apache HBase™ 参考指南 HBase 官方文档中文版 Copyright © 2012 Apache Soft ...
- HBase 官方文档
HBase 官方文档 Copyright © 2010 Apache Software Foundation, 盛大游戏-数据仓库团队-颜开(译) Revision History Revision ...
随机推荐
- redis命令_ZREVRANGEBYSCORE
ZREVRANGEBYSCORE key max min [WITHSCORES] [LIMIT offset count] 返回有序集 key 中, score 值介于 max 和 min 之间(默 ...
- redis命令_INCR
INCR key 将 key 中储存的数字值增一. 如果 key 不存在,那么 key 的值会先被初始化为 0 ,然后再执行 INCR 操作. 如果值包含错误的类型,或字符串类型的值不能表示为数字,那 ...
- jdk8 StreamApi
List<User> userList=new ArrayList<>(); userList.add(User.builder().age().name()).build() ...
- Github上Fork代码,及源码修改
iOS开发中经常遇到这种情况,你使用的第三方库不能完全满足自己项目需要,只能修改源码来解决. 我们以前的解决办法是,添加到项目中直接修改源码.这样就有一个问题,不能和源库同步,当作者更新后你不能(po ...
- java:eclipse-tomcat 配置
计划开始学习java.第一步 1.在servers窗口中新建server 2.弹出的界面选择对应的tomcat版本 3.这里是关键,已存在的项目不要选择过去,否则最后生成的server配置无法修改se ...
- nginx php-fpm安装手记
首先下载nginx,nginx下载地址:http://www.nginx.org/download/nginx-0.8.53.tar.gz[root@winsyk ~]# mkdir -p /usr/ ...
- hdu6005 Pandaland 想法+dijkstra
/** 题目:hdu6005 Pandaland 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6005 题意:给定一个带权无向图,求权值和最小的环的值,如 ...
- db_keep_cache_size參数的控制范围測试
ocm考试新题中.须要创建keep存储的表,但在该參数是否应该改动上,有一些分歧.有人说asmm会自己主动给keep分配内存的,该參数就不用设置了. 看文档和asktom.也是云山雾罩,说什么的都有, ...
- 关于MongoDB最大连接数的查看与修改
一. MongoDB连接数 在Linux平台下,无论是64位或者32位的MongoDB默认最大连接数都是819,WIN平台不知道,估计也没有人在 WIN平台下使用MongoDB做生产环境 [root@ ...
- 第一百五十节,封装库--JavaScript,表单验证--密码验证
封装库--JavaScript,表单验证--密码验证 效果图 html <div id="reg"> <h2 class="tuo">& ...