`
leonzhx
  • 浏览: 786295 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Mongo DB command in Depth

 
阅读更多

1.   The MongoDB command interface provides access to all non CRUD database operations.

 

 

2.   A command is sent to the database as a query to a special collection namespace called $cmd . The database will return a single document with the command results:

db.$cmd.findOne( { <commandname>: <value> [, options] } );
 

 

The shell provides a helper function for this:

db.runCommand( { <commandname>: <value> [, options] } );
 

 

 

3.   All commands return, at minimum, a document with an ok field indicating whether the command has succeeded:

{ 'ok': 1 }
 

 

If the command fails, the value of ok will be 0.

 

4.  For many db commands, some drivers implement wrapper methods to make usage easier. To check our database's current profile level setting:

> db.runCommand({profile:-1});

{

    "was" : 0.0 ,

    "ok" : 1.0

}
 

Or, you can use a corresponding wrapper method:

 

 

> db.getProfilingLevel()

0.0 
 

Its implementation is:

 

> print( db.getProfilingLevel )

function () {

     var res = this._dbCommand({profile:-1});

    return res ? res.was : null;

}

 

> print( db._dbCommand )

function (cmdObj) {

    return this.$cmd.findOne(cmdObj);

} 
 

 

5.  Certain operations are for the database administrator only. These privileged operations may only be performed on the special database named admin :

> use admin;

> db.runCommand("shutdown"); // shut down the database
 

If the db variable is not set to 'admin ', you can use adminCommand (_adminCommand in versions earlier than 1.8 ) to switch to the right database automatically (and just for that operation):

> db.adminCommand("shutdown");
 

6.   Use commandHelp in shell to get help info for a command:

> db.commandHelp("datasize")
 

 

 

7.   For detailed command reference, please refer :

http://docs.mongodb.org/manual/reference/commands/

分享到:
评论

相关推荐

    Mongo DB 可视化工具 robo3t-1.4.3

    Mongo DB 是一个流行的开源、基于文档的分布式数据库系统,它以JSON格式存储数据,适合处理大量半结构化和非结构化数据。可视化工具是管理和操作Mongo DB的重要辅助手段,能够帮助用户更直观地查看和操作数据库。...

    Mongo DB 3.2.5官方帮助文档

    Mongo DB 3.2.5官方帮助文档

    Mongo DB 客户端 破解版

    Mongo DB 客户端 破解版,保证可以使用。

    Mongo DB Training Material

    Mongo DB 基础培训资料,比较详细,是我同事整理总结的

    Mongo DB 安装,Windows下 Mongo DB 服务安装

    mongod --dbpath "C:\data\db" --logpath "C:\MongoDB\logs\mongod.log" --serviceName MongoDB --serviceDisplayName "MongoDB" --install ``` 这些参数含义如下: - `--dbpath` 指定数据文件的存储位置。 - `...

    MONGO DB 安装包3

    MongoDB的实用性着实令人着迷。MongoDB并不去迎合所有人的全部需求。它在功能和复杂性之间取得很好的平衡,并且将原先十分复杂的任务大大简化。也就是说,它具备支撑今天主流web应用的关键功能:索引,复制,分片,...

    mongo DB客户端破解版

    mongoDB客户端破解版使用方法: 解压后安装Installer-1.6.9下的Installer,然后把MongoVUE破解版目录下的MongoVUE拷贝到刚刚你安装的目录下,替换即可。

    sql-to-mongo-db-query-converter:sql-to-mongo-db-query-converter

    sql-to-mongo-db-query-converter sql-to-mongo-db-query-converter可帮助您基于SQL中提供的查询为MongoDb构建查询。玛文向com.github.vincentrussell:sql-to-mongo-db-query-converter添加依赖...

    MONGO DB 安装包1

    MongoDB的实用性着实令人着迷。MongoDB并不去迎合所有人的全部需求。它在功能和复杂性之间取得很好的平衡,并且将原先十分复杂的任务大大简化。也就是说,它具备支撑今天主流web应用的关键功能:索引,复制,分片,...

    MONGO DB 安装包2

    MongoDB的实用性着实令人着迷。MongoDB并不去迎合所有人的全部需求。它在功能和复杂性之间取得很好的平衡,并且将原先十分复杂的任务大大简化。也就是说,它具备支撑今天主流web应用的关键功能:索引,复制,分片,...

    CI框架mongo_db.php

    CI框架的mongo_db数据库扩展链接文件,有了它,CI框架链接mongo_db不在烦恼!

    mongo db demo

    在本"mongo db demo"中,我们将深入探讨MongoDB的基本概念、安装与配置、数据模型、查询操作以及一些高级特性。 一、MongoDB基本概念 1. 文档数据库:MongoDB基于文档存储,其数据模型是JSON格式的BSON(Binary ...

    mongo-sample:用于教育目的的Mongo DB示例代码

    Mongo DB示例代码 这是简单的Rest API中的一些样例Mongo DB代码,该代码具有基本的CRUD终结点,以供参考。 安装 要运行此示例代码,请安装npm软件包并运行server.js文件。 npm install node server Mongo DB入门 ...

    node-mongodb-native, Mongo DB原生NodeJS驱动程序.zip

    node-mongodb-native, Mongo DB原生NodeJS驱动程序 描述官方的 MongoDB驱动程序。 在核心插件之上提供一个高级 API,这意味着最终用户。的MongoDB node.js-驱动程序什么地方文档http://mongodb.github.io

    mongo4ben:适用于Benerator的Mongo DB插件-开源

    Mongo4Ben是一个专门为Benerator设计的Mongo DB插件,它为开发者提供了一个便捷的途径,在Benerator项目中集成和操作Mongo DB数据库。这个插件的出现使得开发人员能够在Mongo数据库实例中进行数据的存储、更新和查询...

    mongo db linux安装包

    MongoDB 是一个基于分布式文件存储的数据库。由 C++ 语言编写。旨在为 WEB 应用提供可扩展的高性能数据存储解决方案。 MongoDB 是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像...

    php-embedded-mongo:启动嵌入式Mongo DB服务器并轻松运行PHPUnit集成测试

    启动嵌入式Mongo DB服务器并轻松运行PHPUnit集成测试。 使用Mongo DB和PHP编写集成测试应该很容易(这是Java语言),该库使您可以在运行测试之前快速启动嵌入式Mongo DB服务器。 安装 该库会启动一个真正的Mongo DB...

    Mongo DB增删改查命令

    switched to db myblog 1.3 列出所有集合 &gt; show collections articles replicationColletion sessions users wangduanduan 2 插入数据 insert(value) // 在已经存在的集合中插入数据 &gt; db.users.insert({name:'...

    dbstream-mongo:与数据库流API兼容的Mongo DB访问层

    与 API兼容的Mongo DB访问层 用法 var db = require ( "dbstream-mongo" ) ; var connection = db . connect ( "mongodb://127.0.0.1:27017/test" , { collection : "test" } ) ; // write or update var cursor = ...

Global site tag (gtag.js) - Google Analytics