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) ...
随机推荐
- element ui 上传图片
upload在form模块,在demo的基础上包个form然后action写地址用?&拼接参数即可
- linux grep find查找文件夹、代码中的某行/字符串
本文转载于:https://blog.csdn.net/Mr_Cat123/article/details/80541658 在Linux中,由于文件很多,代码很长,可能我们只知道其中的一两个字符串, ...
- 原生sql实现restful接口调用
index.php <?php include './Request.php';include './Response.php';//获取数据$data=Request::getRequest( ...
- 为什么会出现container、injection技术?发展历史及未来发展趋势
container 原因: 随着软件开发的发展,相比于早期的集中式应用部署方式,现在的应用基本都是采用分布式的部署方式,一个应用可能包含多种服务或多个模块,因此多种服务可能部署在多种环境中,如虚拟服务 ...
- 并发,同步锁,Runnable,Callable,Future
1.并发: 在我们的操作系统中,同一个时间点,有N个线程都想访问同一个程序!但是cpu只能运行一个! 这种情况就是! 多个线程在 同一个时间点 访问同一个资源,会引发线程不安全的问题! 怎么解决这种不 ...
- day71 菜单的排序 点击被选中
菜单的排序:(给菜单设置权重,权重高的让他显示在上面) from django import template from django.conf import settings from collec ...
- List集合2-LinkedList
一.LinkedList集合 LinkedList集合也是List接口的实现类(没有ArrayList集合常见) 二.LinkedList集合的特点 LinkedList内部是一个链表(双向链表) L ...
- curl: (48) An unknown option was passed in to libcurl怎么解决
想装一个Python版本管理的工具pyenv.结果提示我没有curl.于是从网上百度找到了一篇博客还是不错按照操作提示都成功了.这是那篇博客的地址:https://www.cnblogs.com/su ...
- talk with gao about qssp
- Angular2 NgModule 模块详解
原文 https://segmentfault.com/a/1190000007187393 我们今天要学习的是Angular2的模块系统,一般情况下我们使用一个根模块去启动我们的应用,然后使用许多 ...