美文网首页我爱编程
01 mongodb 官方文档翻译 Configure the

01 mongodb 官方文档翻译 Configure the

作者: Herman7z | 来源:发表于2018-08-09 10:56 被阅读0次

自定义mongodb提示

通过修改 用户home目录下的文件.mongorc.js文件来设置提示

    1. 自定义提示显示操作的行数 ,vim .mongorc.js 添加如下代码
cmdCount = 1;
prompt = function() {
   return (cmdCount++) + "> ";
}
    1. 显示出数据库名字和hostnbame
host = db.serverStatus().host;

prompt = function() {
  return db+"@"+host+"$ ";
}
    1. 为mongo shell扩展一个editor
      在使用mongo之前设置环境变量 EDITOR
export EDITOR=vim
mongo

a. 声明一个function myFunciton
function myFunction(){}
b. 使用editor编辑这个函数
edit myFunction
c. 直接在命令行查看函数定义
myFunction
输出结果:

function myFunction() {
    print("This was edited");
}
    1. 改变mongo的 Batch Size
      db.collection.find() 默认情况下返回数据前20行,可以通过设置改变默认值
      DBQuery.shellBatchSize = 10;

相关文章

网友评论

    本文标题:01 mongodb 官方文档翻译 Configure the

    本文链接:https://www.haomeiwen.com/subject/dmdqbftx.html