1.Configure the mongo Shell-官方文档摘录
Customize the Prompt 自定义提示
You may modify the content of the prompt by setting the variable prompt in the mongo shell. The prompt variable can hold strings as well as JavaScript code. If prompt holds a function that returns a string, mongocan display dynamic information in each prompt.
You can add the logic for the prompt in the .mongorc.js file to set the prompt each time you start up themongo shell.
大概的意思:你可以通过修改mongorc.js这个文件来让你的终端提示符变得不太一样
注意:
# vim /root/.mongorc.js
如果使用yum 装的,这个文件在/root/目录下
Customize Prompt to Display Number of Operations
For example,to create a mongo shell prompt with the number of operations issued in the current session, define the following variables in the mongo shell:
cmdCount = 1;
prompt = function() {
return (cmdCount++) + "> ";
}
The prompt would then resemble the following:
1>
2>
3>
Customize Prompt to Display Database and Hostname
To create a mongo shell prompt in the form of <database>@<hostname>$, define the following variables:
host = db.serverStatus().host;
prompt = function() {
return db+"@"+host+"$ ";
}
The prompt would then resemble the following:
test@myHost1$
Customize Prompt to Display Up Time and Document Count
To create a mongo shell prompt that contains the system up time and the number of documents in the current database, define the following prompt variable in the mongo shell:
prompt = function() {
return "Uptime:"+db.serverStatus().uptime+" Documents:"+db.stats().objects+" > ";
}
The prompt would then resemble the following:
Uptime:5897 Documents:6 >
Use an External Editor in the mongo Shell
You can use your own editor in the mongo shell by setting the EDITOR environment variable before starting the mongo shell.
export EDITOR=vim
mongo
Once in the mongo shell, you can edit with the specified editor by typing edit <variable> or edit<function>, as in the following example:
Define a function
myFunction:function myFunction () { }Edit the function using your editor:
edit myFunction
The command should open the
vimedit session. When finished with the edits, save and exitvimedit session.In the
mongoshell, typemyFunctionto see the function definition:myFunction
The result should be the changes from your saved edit:
function myFunction() {
print("This was edited");
}
NOTE
As mongo shell interprets code edited in an external editor, it may modify code in functions, depending on the JavaScript compiler. For mongo may convert 1+1 to 2 or remove comments. The actual changes affect only the appearance of the code and will vary based on the version of JavaScript used but will not affect the semantics of the code.
以上大概的意思是:通过集中方式来设置显示的方式,需要注意的是mong shell的解释器会依赖于js的版本,即使你使用了编辑器,还是依靠于js的解释器。它只会影响代码的展现而不会影响代码本身的意思
Change the mongo Shell Batch Size
The db.collection.find() method is the JavaScript method to retrieve documents from a collection. Thedb.collection.find() method returns a cursor to the results; however, in the mongo shell, if the returned cursor is not assigned to a variable using the var keyword, then the cursor is automatically iterated up to 20 times to print up to the first 20 documents that match the query. The mongo shell will prompt Typeit to iterate another 20 times.
You can set the DBQuery.shellBatchSize attribute to change the number of documents from the default value of 20, as in the following example which sets it to 10:
DBQuery.shellBatchSize = 10;
大概的意思是:因为在mongo shell中,默认只会将前面20条的结果显示出来,修改默认的显示迭代次数,可以使用
DBQuery.shellBatchSize来设置
1.Configure the mongo Shell-官方文档摘录的更多相关文章
- 2.Access the mongo Shell Help-官方文档摘录
总结: 1.使用help可以查看帮助信息db.help() help等 2.查看对应的实现方法.比如 test@gzxkvm52$ db.updateUser function (name, upd ...
- 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 中,我们为组件提供了方便的计时器,这个计时器源自于 Cocos2d-x 中的 cc.Scheduler,我们将它保留在了 Cocos Creator 中并适配了基于组件 ...
- Cocos Creator 生命周期回调(官方文档摘录)
Cocos Creator 为组件脚本提供了生命周期的回调函数.用户通过定义特定的函数回调在特定的时期编写相关 脚本.目前提供给用户的声明周期回调函数有: onLoad start update la ...
- angular 模板语法(官方文档摘录)
https://angular.cn/guide/template-syntax {{}} 和"" 如果嵌套,{{}}里面求完值,""就是原意 <h3&g ...
- 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官方文档 目录 序 1. 入门 1.1. 介绍 1.2. 快速开始 2. Apache HBase (TM)配置 2.1. 基础条件 2.2. HBase 运行模式: 独立和分布式 2.3. ...
随机推荐
- SVN学习(三)——在Eclipse 中安装和使用SVN客户端插件
0 基本概念了解 0.1 SVN的工作原理:采取客户端/服务器模式——在服务器的版本库中保存项目文件的各个版本,所有参与协同开发的程序员在自己本地电脑上保存一个工作副本.SVN支持程序员将本地副本更新 ...
- 一个请求在Struts2框架中的处理的步骤
- 64位WinRAR5.0破解
在WinRAR安装文件夹下新建文件rarreg.key,用记事本打开rarreg.key把上面的内容复制到记事本再把rarreg.key里保存即可,文件内容如下: RAR registration d ...
- linux 网络性能优化
最近在对程序进行调优,涉及到了网络通信,学习了一下对网络调优的方法,网上的资料很多,针对软件优化方面,大体上主要有两种方式:一是网卡参数,另一个是内核参数. 一. 网卡参数优化 针对网卡参数优化,需要 ...
- .NET 环境中使用RabbitMQ RabbitMQ与Redis队列对比 RabbitMQ入门与使用篇
.NET 环境中使用RabbitMQ 在企业应用系统领域,会面对不同系统之间的通信.集成与整合,尤其当面临异构系统时,这种分布式的调用与通信变得越发重要.其次,系统中一般会有很多对实时性要求不高的 ...
- 自己开发前端调试工具:Gungnir
文章目录 1. 界面介绍 2. 项目资源管理界面 3. 文本编辑器功能 4. 代理功能 4.1. 自动下载线上文件 4.2. 使用本地已有文件 4.3. 代理整个目录 4.4. 执行文件内容后返回结果 ...
- android.app.Service-android:process=":remote"属性解说
在学习Android Service组件的过程中碰到了一个问题,就是在Android应用的声明文件Manifest.xml中有时候会对相关的服务标签设置一个android:process=”:remo ...
- Unity3D - LINEAR INTERPOLATION
原文地址:http://unity3d.com/learn/tutorials/modules/beginner/scripting/linear-interpolation 水平有限,翻译粗略,欢迎 ...
- tcpdump http://www.cnblogs.com/daisin/articles/5512957.html
http://www.cnblogs.com/daisin/articles/5512957.html
- Consul实现原理系列文章2: 用Gossip来做集群成员管理和消息广播
工作中用到了Consul来做服务发现,之后一段时间里,我会陆续发一些文章来讲述Consul实现原理.这篇文章会讲述Consul是如何使用Gossip来做集群成员管理和消息广播的. Consul使用Go ...