0

I'm using this command to replicate a 100mb database

curl -H 'Content-Type: application/json' \
   -X POST http://localhost:5984/_replicate \
   -d '{"source": "http://example.com:5984/bad_name_with_underscore", "target": "good_name"}'

I cannot replicate, because CouchDB says the source database name contains illegal chars. I can understand CouchDB folks discourage user to create bad database name, but reading from it is no harm.

I'm not an admin of source CouchDB, so I tried to export database as JSON and then bulk put to new database. But I met {"error":"bad_request","reason":"Missing JSON list of 'docs'"}. Although I have tried to modify the dump.json by changing the structure to {"docs": [...]}.

I'd like to know, is there any other way I can replicate this database with some underscore in name?

1 Answer 1

0

I have resolved the problem by using a client - PouchDB. Here is the code.

const PouchDB = require('pouchdb')
const source = new PouchDB("http://example.com:5984/bad_name_with_underscore")
source.replicate.to("http://localhost:5984/good_name")
  .on('complete', console.log)
  .on('error', console.error)

This works pretty well, so I post this to share with you all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.