How to create a new database for a new user in CouchDB without a Tier application

I ran into the problem "Private user details in CouchDB". Details on the couchdb wiki page: http://wiki.apache.org/couchdb/PerDocumentAuthorization

I decided to create a new database for each user, because it is best for the applications that I create, and because I have a lot of advice from the community to go along this route.

It’s hard for me to figure out how to do this. Is there a built-in way to do this in CouchDB? So far, I have no other need at the middle or application tier, and I would like to keep this pure couch + htmll5 application. What is the best practice for this?

+4
source share
2 answers

A new feature will add support for automatically creating / deleting a database for each user.

The following section will be added to default.ini and local.ini :

 [couch_peruser] ; If enabled, couch_peruser ensures that a private per-user database ; exists for each document in _users. These databases are writable only ; by the corresponding user. Databases are in the following form: ; userdb-{hex encoded username} enable = true ; If set to true and a user is deleted, the respective database gets ; deleted as well. delete_dbs = true 
+1
source

I think the following line is the easiest way to achieve it:

 curl -X PUT http://127.0.0.1:5984/${user_name} 

PS: I found it here http://guide.couchdb.org/draft/tour.html

0
source

Source: https://habr.com/ru/post/1403342/


All Articles