couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Cottlehuber <>
Subject Re: newbie question, add new documents
Date Mon, 15 Oct 2012 08:10:40 GMT
On 15 October 2012 05:02, A. Lotfi <> wrote:
> Hi,
> I am new to couchDB, just started to read tutorials about it, I found this one :


> In the first page it says :
>  The initial version of our webapp will let us store a mobile number for each person,
so add the following 2 documents:
> view plaincopy to clipboardprint?
>         1. {"type": "address", "name": "Fred", "mobile": "555-0001"}
>         2. {"type": "address", "name": "Barney", "mobile": "555-0002"}
> Is there any way to add ducument as the above jsons, or just add one by one from :
> by clicking New Document. ?
> thanks

You can use any http library to add documents, but command line cURL
is a very good place to start off from with CouchDB.

You can do this to upload a single JSON doc inline, note that CouchDB
will assign a UUID for you in this case:

    curl -Hcontent-type:application/json -XPOST
http://localhost:5984/test1/ --data-binary '<document>'

or include the UUID yourself:

    curl -Hcontent-type:application/json -XPUT
http://localhost:5984/test1/newdoc --data-binary '<document>'

Where document is the JSON body you have above.

You can also use the bulk_docs interface to upload multiple JSON docs,
when they're in a single file:

I suggest you use yajl or some other JSON linter to confirm your JSON
is valid before uploading it. A really common issue is that your text
is not UTF8, even though the characters are valid.


View raw message