3.4. Database Per User

3.4.1. Database Per User Options

[couch_peruser]
enable

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}.

[couch_peruser]
enable = false

Note

The _users database must exist before couch_peruser can be enabled.

Tip

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');
}
delete_dbs

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

[couch_peruser]
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.

q

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

[couch_peruser] q = 1