Skip to content

Commit 819dd49

Browse files
committed
highlight source code
1 parent 2d49e27 commit 819dd49

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

_posts/2015-1-1-MongoDB-Notes.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ category: nosql
66
tags: [mongodb, maizi]
77
---
88

9-
主要还得看官网
9+
MongoDB更新非常快,再好的书或者技术网站都有可能跟不上形势,建议直接看官网。但这里把常用的整理了一下,大家求快可以直接看本网页。
1010

1111
1. 安装命令
1212
{% highlight bash %}
@@ -17,17 +17,19 @@ sudo apt-get install -y mongodb-org
1717
{% endhighlight %}
1818

1919
Try MongoDB: http://try.mongodb.org
20-
21-
停止服务:
22-
sudo service mongod stop
23-
启动服务:
24-
sudo service mongod start
25-
切换数据库
26-
use 数据库名
20+
···
21+
停止服务:
22+
sudo service mongod stop
23+
启动服务:
24+
sudo service mongod start
25+
切换数据库
26+
use 数据库名
27+
···
2728

2829
2. 插入命令
2930

3031
插入数据到students collection
32+
{% highlight javascript %}
3133
db.students.insert({name: "张三", school: {name: "清华大学", city: "北京"}, age: 19, gpa: 3.97})
3234

3335
db.students.insert({name: "李四", school: {name: "北京大学", city: "北京"}, age: 20, gpa: 3.3})
@@ -39,10 +41,10 @@ db.students.insert({name: "小牛", school: {name: "哈工大", city: "哈尔滨
3941
db.students.insert({name: "小马", school: {name: "交通大学", city: "西安"}, age: 21, gpa: 3.70})
4042

4143
db.students.insert({name: "小朱"})
42-
44+
{% endhighlight %}
4345

4446
3. 查询命令
45-
47+
{% highlight javascript %}
4648
值精确匹配的查询
4749
db.students.find({name: "张三"})
4850
两个条件(逻辑与)
@@ -66,7 +68,7 @@ db.students.find({school:{$exists:false}})
6668
基于正则表达式的逻辑查询
6769
db.students.find({name: /^小/})
6870
db.students.find({name: /.*四/})
69-
71+
{% endhighlight %}
7072

7173
3. Update命令
7274

0 commit comments

Comments
 (0)