1. 下载mongo DB(http://www.mongodb.org/display/DOCS/Downloads)并解压。
2. 设定mongo db data 路径,如:D:\Program Files\mongodb-win32-i386-2.4.4\mongodb-data
3. 启动mongo DB:
D:\>cd D:\Program Files\mongodb-win32-i386-2.4.4\bin
D:\Program Files\mongodb-win32-i386-2.4.4\bin>mongod -dbpath ..\mongodb-data
访问服务: http://localhost:27017/
4. 另外开一个窗口,可以执行mongo命令
D:\Program Files\mongodb-win32-i386-2.4.4\bin>mongo
>show dbs
>use xx
more --> http://www.cnblogs.com/xumingxiang/archive/2012/04/08/2437468.html
To install plugin:
grails install-plugin rest (? x)
grails install-plugin restapidoc
===========================================================================
Below are the scripts they should be useful for us:
- show dbs;
- use <dbname>;
- show collections;
- db.<collection>.count();
- db.<collection>.find()
- db.<collection>.findOne()
- db.<collection>.find({"_id":"1031"})
- db.<collection>.find({"<node1>.<node2>.<node3>.<node4>":false}).count();
-
db.<collection>.save({"<node1>":"123","<node2>":{"<node3>":"abc","<node4>":111}})
-
db.<collection>.update({"<node1>":"1234"},{"$set":{"<node3>.<node4>":123}},upsert=true,multi=true) // insert if not exists, and allow multiple update
- db.<collection>.remove({"<node1>":"123"})