想用一下MONGO DB,结果发现基本操作都忘记了 = =    

再找一下记录一下

service

1
2
3
4
5
sudo service mongodb start
sudo service mongodb stop

sudo systemctl start mongodb
sudo systemctl stop mongodb

CRUD

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$ mongo

db.stats()
db.help()

show dbs
use <dbname>

show collections

db.user.insert({name:'mr.a', age:10, gender:'m', hobbies:['programming']});

db.<collection-name>.find()
db.user.find( {name:'ms.c'} )
db.user.find({age:{$gte:20}})

db.コレクション名.update({検索条件}, {更新内容})
db.counter.update( {type:'success'} ,{$inc:{count:1}}, true)

db.user.remove({age:{$gte:30}})

REF


creativ common license