本节主要讲述怎么去学习好shell
1.利用shell自带的帮助命令
> help
db.help() help on db methods
db.mycoll.help() help on collection methods
rs.help() help on replica set methods
help connect connecting to a db help
help admin administrative help
help misc misc things to know
help mr mapreduce help
show dbs show database names
show collections show collections in current database
show users show users in current database
show profile show most recent system.profile entries wit
h time >= 1ms
use <db_name> set current database
db.foo.find() list objects in collection foo
db.foo.find( { a : 1 } ) list objects in foo where a == 1
it result of the last line evaluated; use to f
urther iterate
DBQuery.shellBatchSize = x set default number of items to display on s
hell
exit quit the mongo shell
2.使用db.help()查看数据库级别命令的帮助
> db.help();
DB methods:
db.addUser(username, password[, readOnly=false])
db.auth(username, password)
db.cloneDatabase(fromhost)
db.commandHelp(name) returns the help for the command
db.copyDatabase(fromdb, todb, fromhost)
db.createCollection(name, { size : ..., capped : ..., max : ... } )
db.currentOp() displays the current operation in the db
db.dropDatabase()
db.eval(func, args) run code server-side
db.getCollection(cname) same as db['cname'] or db.cname
db.getCollectionNames()
db.getLastError() - just returns the err msg string
db.getLastErrorObj() - return full status object
db.getMongo() get the server connection object
db.getMongo().setSlaveOk() allow this connection to read from the nonma
ter member of a replica pair
db.getName()
db.getPrevError()
db.getProfilingLevel() - deprecated
db.getProfilingStatus() - returns if profiling is on and slow threshold
2.使用db.foo.help()查看集合相关帮助
> db.blog.help()
DBCollection help
db.blog.find().help() - show DBCursor help
db.blog.count()
db.blog.dataSize()
db.blog.distinct( key ) - eg. db.blog.distinct( 'x' )
db.blog.drop() drop the collection
db.blog.dropIndex(name)
db.blog.dropIndexes()
db.blog.ensureIndex(keypattern[,options]) - options is an object with th
ese possible fields: name, unique, dropDups
db.blog.reIndex()
db.blog.find([query],[fields]) - query is an optional query filter. fiel
ds is optional set of fields to return.
e.g. db.blog.find( {x:77}
, {name:1, x:1} )
db.blog.find(...).count()
db.blog.find(...).limit(n)
db.blog.find(...).skip(n)
db.blog.find(...).sort(...)
db.blog.findOne([query])
db.blog.findAndModify( { update : ... , remove : bool [, query: {}, sort
: {}, 'new': false] } )
db.blog.getDB() get DB object associated with collection
4.查看函数的JavaScript源码
> db.blog.find
function (query, fields, limit, skip) {
return new DBQuery(this._mongo, this._db, this, this._fullName, this._massag
eObject(query), fields, limit, skip);
}
分享到:
相关推荐
本文实例讲述了MongoDB Shell 命令。分享给大家供大家参考,具体如下: 原始文件请到我的github上去下载:https://github.com/yangqingxian/mongodb 这里先讲几件事: 1、这是第三次修改这篇文章了,也是第一次正真...
MongoDB学习手册 说明 一、 Mongodb简介 二、 MongoDB特性 适用场景: 不适用场景: 三、 MongoDB的工作方式 四、 MongoDB的下载 五、 MongoDB的安装 六、 MongoDB数据类型 1. Timestamp类型 2. ObjectId...
MongoDB客户端访问(Shell方式 ) .pdf 学习资料 复习资料 教学资源
MongoDB学习手册 ......................................................................................................................... 1 说明..........................................................
MONGODB SHELL MONGODB的数据类型 MONGODB的基本数据类型 MONGODB的数组 MONGODB的文档嵌套 MONGODB的OBJECTID 结束语 第二天:初识增删改 添加文档 删除文档 更新文档-文档更换1 更新文档-文档替换2 更新文档-...
MongoDB学习手册 ......................................................................................................................... 1 说明...........................................................
该资源主要对MongoDB数据库进行了详细的描述,其中包括其shell脚本语言、该数据的特点等等。
:books: 学习和探索MongoDB。 注意:这是在macOS上开发的。 指示 作为先决条件,您必须安装Mongo。 有关选项,请参见“部分。 启动MongoDB服务器 使用来自佐治亚州(GA)的邮政编码测试数据加载数据库(这是来自...
2. 适合MongoDB初学者:降低学习成本,底层实现对使用者透明,操作简单,提升开发效率 3. 适合从RDB(关系型数据库)刚转用MongoDB的使用者:此封装照顾了 MySQL等RDB使用者的用户习惯,返回的数据格式和ORM(关系...
mongodb-runrs 仅使用一个命令即可运行用于学习和开发的MongoDB副本集。介绍设置MongoDB副本集是一个复杂的过程,需要进行许多配置。 使用mongodb-runrs,您现在可以调用单个命令以在不到60秒的时间内设置N成员副本...
最好回到《mongodb shell基础命令【进阶篇】》,再来看这里的内容,否则有些东西我讲的比较笼统。 好了,不废话了,直接贴代码吧,别害怕看代码,基本每行都写了注释了 <!-- 1、本文采用mongoClient类来实现...
小小最近接触了MongoDB,所以这里开始学习MongoDB,之用户管理模块的相关内容。 进入MongoDB的Shell 这里输入如下的命令,进入MongoDB的shell mongo 切换数据库 use admin 使用如上的命令,切换数据库到admin...
在这里,我们将对MongoDB进行一些练习,我们将讨论Mongo Shell,如何配置MongoDB,MongoDB中的索引是什么,等等。
最初是为了学习Docker并学习使用Docker从零开始构建MongoDB部署而实现的 我知道这还有很大的改进空间:) 主要脚本 这是使用Docker容器配置,部署和运行MongoDB的主要脚本。 这里,我们有几个功能可以简化部署过程中...
学习MongoDB使用,windows安装MongoDB连接工具,有命令shell。
这是探索Mongo Shell的延续,我们将在Mongo Shell上执行一些命令。
```shell python app.py ``` #### 使用说明 1. app 文件夹中保存项目的核心代码,提供数据访问接口,返回网页,训练模型,生成模型,验证图片等 2. face_login_app 文件夹中保存移动端代码,使用weui+vue,...
学习猫鼬NoSQL与SQL SQL(MySQL) NoSQL(몽고디비) 데이데 자유로운이데 테이블JOIN지원 INJOIN미지원 안정성,일관성 ,가용성 테이블 컬렉션 로우 도큐먼트 컬럼 필드mongodb설치 ╰─$ brew tap mongodb/brew╰...