couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Audrey Lee <audrey.lee.is...@gmail.com>
Subject Newb: curl, javascript, jQuery.ajax, bad-browsers, rest-client rubygem?
Date Thu, 01 Apr 2010 20:02:05 GMT
Dear couchDB List,

I am a couchDB beginner.

I installed this couchDB version on my Mac:
  - 0.10

Today I finished a quick study of the futon-UI.

Now I like futon.

After futon I made the next step up which perhaps might be curl.

I got all these curl commands to work on my Mac:

Create a DB:
  - curl -X PUT http://127.0.0.1:5984/audreydb

Create a document:
  - curl -X PUT -d '{"_id":"audreydoc10","name":"i_am_audreydoc10" }'
localhost:5984/audreydb/audreydoc10

A curl command which reads my JSON from a file rather than from the
command line:
  - curl -X PUT -T my_json.json localhost:5984/audreydb/audreydoc176

List all DB:
  - curl -X GET http://127.0.0.1:5984/_all_dbs

Delete DB:
  - curl -X DELETE http://127.0.0.1:5984/contacts

Get a document (useful for getting a rev):
  - curl -X GET http://127.0.0.1:5984/audreydb/audreydoc176

Delete a doc (GET a rev 1st):
  - curl -X DELETE
http://127.0.0.1:5984/audreydb/audreydoc176?rev="1-a67cc301ab176c5561899d7bae78bbb7"

Copy a doc:
  - curl -X COPY http://127.0.0.1:5984/audreydb/audreydoc176 -H
"Destination: audreydoc176_copy"

Update a doc:
  - do a GET to get the rev:
  - curl -X GET http://127.0.0.1:5984/audreydb/audreydoc176
  - curl -X PUT http://127.0.0.1:5984/audreydb/audreydoc176 -d
'{"_rev":"3-204132c15193747f9962fe1284a6a5bf", "name":"my doc"}'

List all documents:
  - curl -X GET http://127.0.0.1:5984/audreydb/_all_docs

get db info:
  - curl -X GET http://127.0.0.1:5984/audreydb

List all documents (ORDER and set LIMIT)
  - curl -X GET
http://127.0.0.1:5984/audreydb/_all_docs?descending=true\&limit=1

All documents in the DB (as well as deleted ones):
  - curl -X GET http://127.0.0.1:5984/audreydb/_all_docs_by_seq

Now that I can do simple curl commands I think perhaps the next step
up would be JavaScript.

I dislike JavaScript so I tend to use jQuery when possible.

It appears that I can use jQuery to send GET, POST, PUT, and DELETE
requests to couchDB:

  - http://api.jquery.com/jQuery.ajax/

The above page states that some browsers don't support PUT and DELETE.

I think perhaps that if I have a problem with these bad-browsers I
could have the bad-browser use a POST to ask a rails server to
construct a PUT or DELETE which might then leverage the rest-client
rubygem to do the deed.

So, here are my questions:

1. Are any of you using JavaScript to send requests to couchDB?

2. Have you bumped into issues with "bad-browsers"?

3. Are any of you using jQuery.ajax to send requests to couchDB?

4. If yes, do you like jQuery.ajax?

5. Are any of you using the rest-client rubygem to create proper REST
requests using signals from browsers?

ref:
  - http://rdoc.info/projects/archiloque/rest-client

Today that is all I'm curious about; I might have more questions tomorrow.

Thanks!

Mime
View raw message