couchdb-mkdb
couchdb-mkdb
makes it easy to create databases and stream couchdb's response.
Installation
$ npm i -S couchdb-mkdb
Usage
Express example
This express route creates new databases on every request.
...
app.post('/', (req, res, next) => {
let name = 'mydb-' + uuid.v1();
let opts = {
couchdb: app.get('couchdb'),
security: {
admins: {names: [req.user.name], roles: []},
members: {names: [], roles: []}
},
oauth: app.get('auth')
};
mkdb(name, opts, (err, response) => {
if (err) return next(err);
response.pipe(
res.set(response.headers)
.status(response.statusCode)
);
});
});
API
mkdb(name, [opts], callback)
name
The name of the databaseopts
Optional options object. See belowcallback
Function with the signature fn(error, response)
Available options are:
couchdb
The url to the couchdbsecurity
The security rules to apply to the database. See Couchdb security
All other options are passed to the underlaying request function.