test mongodb

to start mongo in REST mode, use ./bin/mongod --dbpath ./data/db -rest

 

to access it by REST, use https://github.com/tdegrunt/mongodb-rest(other approach http://www.mongodb.org/display/DOCS/Http+Interface)

 

to install mongodb-rest, use npm. install npm. you need use root mode. after install, to find where is command, use "npm bin" to show where is bin direcotry. It is not within default path.

 

use curl -d '{ "A1" : 201 }' -H "Content-Type: application/json" http://localhost:3000/test/example1 to create data. Here Chinese character is supported.

  -d means --data, -H means header

 

then http://localhost:28017/test/example1/ will show the data you just added. the all '/' in url are necessary.

 

So to add data, you need 1) start mogodb demon, 2)start mongodb-rest server, 3) use curl to add

 

to query, access http://localhost:28017/test/example1/?filter_A1=我草

Oh, cool, it support Chinese.

 

1. 如果出现node.js Error: Cannot find module './colors',用export NODE_PATH=/opt/local/lib/node_modules/

你可能感兴趣的:(mongodb)