3.4. Database Per User

3.4.1. Database Per User Options


If set to true, couch_peruser ensures that a private per-user database exists for each document in _users. These databases are writable only by the corresponding user. Database names are in the following form: userdb-{UTF-8 hex encoded username}.

enable = false


The _users database must exist before couch_peruser can be enabled.


Under NodeJS, user names can be converted to and from database names thusly:

function dbNameToUsername(prefixedHexName) {
  return Buffer.from(prefixedHexName.replace('userdb-', ''), 'hex').toString('utf8');

function usernameToDbName(name) {
  return 'userdb-' + Buffer.from(name).toString('hex');

If set to true and a user is deleted, the respective database gets deleted as well.

delete_dbs = false

Note: When using JWT authorization, the provided token must include a custom _couchdb.roles=['_admin'] claim to for the peruser database to be properly created and accessible for the user provided in the sub= claim.


If set, specify the sharding value for per-user databases. If unset, the cluster default value will be used.

[couch_peruser] q = 1