Is it good practice to give each CouchDB user a separate database?

前端 未结 4 896
情话喂你
情话喂你 2021-02-15 00:39

I have a bit of conceptual question regarding the structure of users and their documents.

Is it a good practice to give each user within CouchDB their own databa

4条回答
  •  感动是毒
    2021-02-15 01:03

    Using multiple database for multiple users have some important drawbacks:

    • queries over data in different databases are not possible with the native couchdb API. Analysis on your website overall status are quite impossible!
    • maintenance will soon becomes very hard: let's think of replicating/compacting thousands of database each time you want to perform a backup

    It depends on your use case, but I think that a nice approach can be:

    1. allow access only through virtual host. This can be achieved using a proxy or much more simply by using a couchdb hosting provider which lets you fine-tune your "domains->path" mapping

    2. use design docs / couchapps, instead of direct document CRUD API, for read/write operations

      2.1. using _rewrite handler to allow only valid requests: in this way you can instantly block access to sensible handlers like _all_docs, _all_dbs and others

      2.2. using _list and _view handlers for read doc/role based ACLs as described in CouchDb read authentication using list

      2.3. using _update handlers for write doc/role based ACLs

      2.4. using authenticated rewriting rules for read/write role based ACL.

      2.3. filtered _changes handler is another way of retrieving all user's data with read doc/role based ACL. Depending on your use case this can effectively simplify as much as possible your read API, letting you concentrate on your update API.

提交回复
热议问题