If you made it through the installation process and successfully started CouchDB then you could use your browser to get familiar with CouchDB or you could use curl.
I used curl because it is command line driven, fast and gets the job done.
Test access:
curl http://localhost:5984/
A response of {"couchdb": "Welcome", "version": "0.8.0-incubating"} will indicate we are ready.
If you do not get this response then check to make sure Couchdb is running.
You can also go to the browser to double check: http://localhost:5984.
Creating a database:
curl -X PUT http://localhost:5984/mydemodb/
A repsonse of {"ok",true} will indicate that the database was created. If you get an illegal name error then check your database name. Is it all lower case, no spaces, no special characters?
Deleting a database:
curl -X DELETE http://localhost:5984/mydemodb/
Adding data to the database:
Presuming a database was created, create a testdata.dat file with your data. Here is an example:
{
"field1": "value1",
"field2": "value2"
}
Enter the command to save the data:
curl -T testdata.dat -X POST http://localhost:5984/mydemodb/
With a response of:
{"ok": true, "id": "...", "rev":"..."}
No comments:
Post a Comment