使用mongodb 的基本命令 ( basic commands for mongodb)

访问量: 1483

说实话,我觉得挺奇怪的,不能自动的 repair, 然后启动吗?  名字还叫做 fork... 叫daemon 多好理解啊哥哥。。。

启动(start):  sudo mongod -f /etc/mongodb.conf --fork

系统不正常关机之后,需要修复(repair):  sudo mongod -f /etc/mongodb.conf --repair

加入embed记录:(insert embedded record)

> show collections;
destricts
districts
system.indexes
> db.destricts.remove()
> db.districts.find()
{ "_id" : ObjectId("503312e519cdff8116fbe353"), "name" : "haizhouqu" }
{ "_id" : ObjectId("5033131119cdff8116fbe354"), "name" : "taipingqu", "child_locations" : { "name" : "zhonghualu" } }
> street1 = { "name": "jiefangdajie"}
{ "name" : "jiefangdajie" }
> street2 = {"name" : 'zhonghualu'}
{ "name" : "zhonghualu" }
> db.districts.insert({'name': 'xihequ', child_locations: [street1, street2]})
> db.districts.find()
{ "_id" : ObjectId("503312e519cdff8116fbe353"), "name" : "haizhouqu" }
{ "_id" : ObjectId("5033131119cdff8116fbe354"), "name" : "taipingqu", "child_locations" : { "name" : "zhonghualu" } }
{ "_id" : ObjectId("50331415bb69e1c371096a6b"), "name" : "xihequ", "child_locations" : [ { "name" : "jiefangdajie" }, { "name" : "zhonghualu" } ] }
> 

订阅/RSS Feed

Subscribe

分类/category