import a large amount of json files to couchdb

1.5k Views Asked by At

i 'm new to couchdb and managing a directory with json files (>300) that need to be imported on an existing database (this will be happenning e.g. every week). My question has basically 2 parts that are probably relative:

  • Could someone recommend a high-level solution to my workflow? ( e.g. read the dir contents, use couchdb bulk api to post) I would favor involving php. I 've read several posts but i am not sure that they fit easily to my case.

  • My Json files start and end with brackets [] and when i use

    curl -X PUT -d @name.json http://user:[email protected]:5984/db/doc
    

    i get a fail due to "Document must be a JSON object"

    Is there a way to remove them?

Thanks

1

There are 1 best solutions below

0
On BEST ANSWER

Make sure you are posting to the _bulk_docs endpoint (e.g. http://user:[email protected]:5984/db/_bulk_docs).

See here for more info.