MongoDB基础知识(二)

> show dbs;
admin .000GB
local .000GB
> use testdb;
switched to db testdb
> post={"title":"My Blog Post",
... "content":"HaHa",
... "date":new Date()}
{
"title" : "My Blog Post",
"content" : "HaHa",
"date" : ISODate("2017-07-07T03:20:44.698Z")
}
> db.blog.insert(post)
WriteResult({ "nInserted" : })
> db.blog.find()
{ "_id" : ObjectId("595efe1af713ea7372854b9c"), "title" : "My Blog Post", "content" : "HaHa", "date" : ISODate("2017-07-07T03:20:44.698Z") }
> db.blog.findOne()
{
"_id" : ObjectId("595efe1af713ea7372854b9c"),
"title" : "My Blog Post",
"content" : "HaHa",
"date" : ISODate("2017-07-07T03:20:44.698Z")
}
> post.comments=[]
[ ]
> db.blog.update({"_id":ObjectId("595efe1af713ea7372854b9c")},post)
WriteResult({ "nMatched" : , "nUpserted" : , "nModified" : })
> db.blog.findOne()
{
"_id" : ObjectId("595efe1af713ea7372854b9c"),
"title" : "My Blog Post",
"content" : "HaHa",
"date" : ISODate("2017-07-07T03:20:44.698Z"),
"comments" : [ ]
}
> db.blog.remove({"_id":ObjectId("595efe1af713ea7372854b9c")})
WriteResult({ "nRemoved" : })
> db.blog.findOne()
null
可以看到,集合内没有文档了
> help
db.help() help on db methods
db.mycoll.help() help on collection methods
sh.help() sharding helpers
rs.help() replica set helpers
help admin administrative help
help connect connecting to a db help
help keys key shortcuts
help misc misc things to know
help mr mapreduce
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 with time >= 1ms
show logs show the accessible logger names
show log [name] prints out the last segment of log in memory, 'global' is default
use <db_name> set current database
db.foo.find() list objects in collection foo
db.foo.find( { a : } ) list objects in foo where a ==
it result of the last line evaluated; use to further iterate
DBQuery.shellBatchSize = x set default number of items to display on shell
exit quit the mongo shell
MongoDB基础知识(二)的更多相关文章
- DataBase MongoDB基础知识记录
MongoDB基础知识记录 一.概念: 讲mongdb就必须提一下nosql,因为mongdb是nosql的代表作: NoSQL(Not Only SQL ),意即“不仅仅是SQL” ,指的是非关系型 ...
- MongoDB基础知识记录
MongoDB基础知识记录 一.概念: 讲mongdb就必须提一下nosql,因为mongdb是nosql的代表作: NoSQL(Not Only SQL ),意即“不仅仅是SQL” ,指的是非关系型 ...
- MongoDB基础知识 02
MongoDB基础知识 02 6 数据类型 6.1 null : 表示空值或者不存在的字段 {"x":null} 6.2 布尔型 : 布尔类型只有两个值true和false {&q ...
- MongoDB基础知识 01
MongoDB基础知识 1. 文档 文档是MongoDB中的数据的基本单元,类似于关系型数据库管理系统的行. 文档是键值对的一个有序集.通常包含一个或者多个键值对. 例如: {”greeting& ...
- java 基础知识二 基本类型与运算符
java 基础知识二 基本类型与运算符 1.标识符 定义:为类.方法.变量起的名称 由大小写字母.数字.下划线(_)和美元符号($)组成,同时不能以数字开头 2.关键字 java语言保留特殊含义或者 ...
- 菜鸟脱壳之脱壳的基础知识(二) ——DUMP的原理
菜鸟脱壳之脱壳的基础知识(二)——DUMP的原理当外壳的执行完毕后,会跳到原来的程序的入口点,即Entry Point,也可以称作OEP!当一般加密强度不是很大的壳,会在壳的末尾有一个大的跨段,跳向O ...
- Mongodb 笔记01 MongoDB 简介、MongoDB基础知识、启动和停止MongoDB
MongoDB 简介 1. 易于使用:没有固定的模式,根据需要添加和删除字段更加容易 2. 易于扩展:MongoDB的设计采用横向扩展.面向文档的数据模型使它能很容易的再多台服务器之间进行分割.自动处 ...
- Dapper基础知识二
在下刚毕业工作,之前实习有用到Dapper?这几天新项目想用上Dapper,在下比较菜鸟,这块只是个人对Dapper的一种总结. 2,如何使用Dapper? 首先Dapper是支持多种数据库的 ...
- python基础知识(二)
python基础知识(二) 字符串格式化 格式: % 类型 ---- > ' %类型 ' %(数据) %s 字符串 print(' %s is boy'%('tom')) ----> ...
- 常见问题:MongoDB基础知识
常见问题:MongoDB基础知识 ·MongoDB支持哪些平台? ·MongoDB作为托管服务提供吗? ·集合(collection)与表(table)有何不同? ·如何创建数据库(database) ...
随机推荐
- 线程(四)之Queue
SynchronousQueue SynchronousQueue是无界的,是一种无缓冲的等待队列,但是由于该Queue本身的特性,在某次添加元素后必须等待其他线程取走后才能继续添加:可以认为Sync ...
- double 类型转化为Integer
(1)把double先转化成int类型 Double reseve3=Double.parseDouble(bddet[0].getReserve3()); int b=reseve3.intValu ...
- java ----> 注解/反射
注解 一个例子,摘自Junit-4.12.jar源码. 1 @Retention(RetentionPolicy.RUNTIME) 2 @Target({java.lang.annotation.El ...
- Openstack中用秘钥对(keypair)生成和访问虚机的方法
Openstack中用镜像文件生成的image来创建虚机(VM或Instance)时, 通常不支持用户名加密码的ssh方式登录访问该VM,而是用秘钥对(keypair)方式. 这里以Centos的镜像 ...
- JS中输出EL表达式
要在javascript中使用El表达式,需要在el表达式两端加上单引号或者双引号 <script type="text/javascript"> jQuery(doc ...
- Matlab:高阶常微分三种边界条件的特殊解法(隐式Euler)
函数文件1: function b=F(f,x0,u,h) b(1,1)=x0(1)-h*x0(2)-u(1); b(2,1)=x0(2)+h*x0(1)^2-u(2)-h*f; 函数文件2: fun ...
- zzw原创_非root用户启动apache的问题解决(非root用户启动apache的1024以下端口)
场景:普通用户编译的apache,要在该用户下启动1024端口以下的apache端口 1.假设普通用户为sims20,用该用户编译 安装了一个apache,安装路径为/opt/aspire/produ ...
- sql语句查询结果合并union all用法
整理别人的sql 大概的思想是用union 和union all --合并重复行select * from Aunion select * from B --不合并重复行select * from A ...
- 破解 JS(原型)继承
总体分为四大类:利用空对象作为中介继承.Object.create 继承.setPrototypeOf 继承.拷贝继承 function Animal(name, age) { this.name = ...
- python魔术方法(__init__,__call__,被双下划线包围的方法)
转载link:http://pycoders-weekly-chinese.readthedocs.io/en/latest/issue6/a-guide-to-pythons-magic-metho ...