1.
If a line contains open '(' or
'{' characters, the shell will request more input before evaluating. You can
press Enter twice to terminate line entry.
2.
Key Shortcuts:
a)
up/down array for command
history
b)
in v1.9+ some basic emacs
keystrokes work
c)
ctrl-l to clear the screen
d)
tab for auto-complete (newer
versions only)
e)
ctrl-c to exit
f)
Enter twice to break out of
line continuation mode
3.
The shell's prompt can be
customized by creating variable 'prompt' in the shell. It can be any arbitrary
javascript, including a function that returns a string:
> cmdCount = 1;
> prompt = function() {
... return (cmdCount++) + "> ";
... }
1> command
2> anothercommand
3>
4.
We've added a feature to allow
you edit larger values including functions using your editor of choice. Just
run edit nameOfVariableOrFunction
and we will open whatever editor you
have defined in your EDITOR
environment variable. Make
sure that you save the file when editing. If you wish to discard your changes,
you can either not save or make your editor exit with an error (:cq in Vim or (kill-emacs
1) in Emacs).
5. B
y default, the shell treats
all numbers as floating-point values. You have the option to work with 64 bit
integers by using a class built into the shell called NumberLong()
.
6.
The Date()
function returns a
string and a "new
Date()
"
will return an object (which is what you should use to store values).
7.
The BSON
BinData datatype is represented via class BinData
in the shell. Run help
misc
for more information.
8.
The MongoDB shell is not just
an interactive shell, it can also be scripted using JS files:
./mongo server:27017/dbname --quiet my_commands.js
This command will execute the my_commands.js
as if it had
been entered into the shell directly.
9.
--quiet
is a flag for the mongo
command. This switch removes some header information that is not typically
necessary when building unattended scripts.
10.
In addition to using a full
Javascript file you can also pass in a Javascript fragment:
./mongo test --eval "printjson(db.getCollectionNames())"
11.
use dbname
does not work in scripted mode. Instead you will need to explicitly
define the database in the connection. Alternately, you can also create a
connection within the script. Or you can use:
> db = db.getSiblingDB("otherdb")
12. The iterator command it
does not work outside of the interactive scripting environment.
13. When running an update/insert command
from the shell, the shell automatically awaits a reply (i.e. runs a get last
error
). The same is not true when running from a script file. To wait for
the status of an operation (such as a write), run the getLastError
function after update/insert.
分享到:
相关推荐
MongoDB Community Server(mongodb-shell-linux-x86_64-debian10-5.0.4.tgz)适用于Debian10 MongoDB是一个基于分布式文件存储的数据库。由C++语言编写。旨在为WEB应用提供可扩展的高性能数据存储解决方案。 ...
MongoDB Community Server(mongodb-shell-linux-x86_64-rhel70-5.0.4.tgz)适用于RedHat / CentOS 7.0 MongoDB是一个基于分布式文件存储的数据库。由C++语言编写。旨在为WEB应用提供可扩展的高性能数据存储解决方案...
Mongodb备份数据库的shell脚本文件, 经过在实际项目中测试使用过.
标题中的“PyPI 官网下载 | mongodbshell-0.1a4.tar.gz”表明这是一个在Python Package Index(PyPI)上发布的软件包,名为`mongodbshell`,版本为0.1a4,且文件格式为tar.gz。PyPI是Python开发者发布自己编写的模块...
MongoDB Community Server(mongodb-shell-linux-x86_64-suse12-5.0.4.tgz)适用于SUSE12 MongoDB是一个基于分布式文件存储的数据库。由C++语言编写。旨在为WEB应用提供可扩展的高性能数据存储解决方案。 MongoDB是...
MongoDB Community Server(mongodb-shell-linux-x86_64-suse15-5.0.4.tgz)适用于SUSE15 MongoDB是一个基于分布式文件存储的数据库。由C++语言编写。旨在为WEB应用提供可扩展的高性能数据存储解决方案。 MongoDB是...
sysbench-mongo 是一个用 JavaScript 编写的工具,可以在 MongoDB 的 JavaScript shell 中运行,提供了对 MongoDB 性能基准测试的能力。这个工具的主要目标是帮助开发者和管理员评估 MongoDB 在不同工作负载下的表现...
6.0 版本以上的mongodb不提供,shell脚本需要自己安装使用
windows版本 mongodb shell:mongosh-2.2.6-win32-x64.zip mongodb shell :https://www.mongodb.com/try/download/shell mongodb相关官网下载地址: mongodb社区版:...
mongodb-org-shell ,包含mongo shell。 mongodb-org-tools ,包含以下MongoDB工具:mongoimport bsondump,mongodump,mongoexport,mongofiles,mongorestore,mongostat和mongotop。 docker build --rm -t ...
mongodb shell指令,在后台shell进行数据操作!
// Now, lets add lots of little documents to the collection so we can explore queries and cursors for (var i=0; i ; i ) { coll.insert({"i": i}); } print(coll.getCount()); // Let's get all the ...
MongoDB Community Server(mongodb-org-shell-5.0.4-1.el7.x86_64.rpm)适用于RedHat / CentOS 7.0 MongoDB是一个基于分布式文件存储的数据库。由C++语言编写。旨在为WEB应用提供可扩展的高性能数据存储解决方案。 ...
MongoDB Community Server(mongodb-org-shell-5.0.4-1.suse12.x86_64.rpm)适用于SUSE12 MongoDB是一个基于分布式文件存储的数据库。由C++语言编写。旨在为WEB应用提供可扩展的高性能数据存储解决方案。 MongoDB是...
Zoran Maksimovic’s MongoDB 3 Succinctly touches on the most important aspects of the MongoDB database that application developers should be aware of—from installation and the usage of the Mongo ...
mongoDB shell-2.2.10-win32-x64安装包 mongoDB shell-2.2.10-win32-x64安装包 mongoDB shell-2.2.10-win32-x64安装包 mongoDB shell-2.2.10-win32-x64安装包
MongoDB Community Server(mongodb-org-shell_5.0.4_amd64.deb)适用于适用于Debian10 MongoDB是一个基于分布式文件存储的数据库。由C++语言编写。旨在为WEB应用提供可扩展的高性能数据存储解决方案。 MongoDB是一...
MongoDB的一个独特之处在于它不使用传统的SQL语句,而是通过MongoDB Shell来执行各种操作,因此掌握其Shell命令对于使用MongoDB进行开发和维护至关重要。 在MongoDB中,基本的数据单位是文档,文档中的数据是以键值...
MongoDB Community Server(mongodb-org-shell-5.0.4-1.suse15.x86_64.rpm)适用于SUSE15 MongoDB是一个基于分布式文件存储的数据库。由C++语言编写。旨在为WEB应用提供可扩展的高性能数据存储解决方案。 MongoDB是...
实现mongodb自定义备份,可实现自定义库、自定义集合、自定义备份周期,使用方便,脚本易维护!