couchdb-bootstrap icon indicating copy to clipboard operation
couchdb-bootstrap copied to clipboard

_config.json as configuration object

Open layanto opened this issue 7 years ago • 6 comments

How do I use configuration object for _config.json? I want to use couchdb-bootstrap to initialise a new installation of couchdb so configuration are always the same.

layanto avatar Sep 13 '18 07:09 layanto

Hi, https://github.com/jo/couchdb-configure can configure CouchDB via HTTP config endpoint. Here you see examples for a config object.

For CouchDB 2 you need to change the endpoint, though. See http://docs.couchdb.org/en/stable/http-api.html#cap-/_node/{node-name}/_config. This has not been tested yet with couchdb-bootstrap and I am not sure whether it works out of the box. Feedback appreciated.

jo avatar Sep 13 '18 07:09 jo

If I do this:

const config = {
    "couchdb-configure": {
        "vendor": {
            "name": "Custom Vendor ABC"
        }
    }
}

bootstrap('http://username:password@localhost:5984', config, function(error, response) {
    if (error) console.log(error)
    else console.log(response)
})

I ended up creating a new db called couchdb-configure I am using couchDB 2.2.0

layanto avatar Sep 13 '18 07:09 layanto

How do I change the endpoint?

How does bootstrap know to pass that part of the configuration object to couchdb-configure instead of couchdb-push?

layanto avatar Sep 13 '18 21:09 layanto

Yeah, looks like this is not possible atm. You can use couchdb-configure standalone for the time being.

jo avatar Sep 14 '18 08:09 jo

Had a look through source of couchdb-bootstrap and couchdb-configure. Configuration object for _config should be:

const config = {
    "_config": {
        "name": "Custom Vendor ABC"
    }
}

Currently couchdb-configure hardcodes the _config path as '_config' via line 35 of https://github.com/jo/couchdb-configure/blob/master/index.js

path: '_config/' + setting.path,

Maybe the fix is for couchdb-configure to GET / to find out the version of couchdb server. If version 1.x, do as is. If version 2.x, change to

path: '_node/_local/_config/' + setting.path,

layanto avatar Sep 15 '18 02:09 layanto

Related to jo/couchdb-configure#15

layanto avatar Sep 15 '18 22:09 layanto