Is there any possibility at CouchDB or Cloudant to hide documents for users?
- I have 2 Member roles
roleAandroleBassigned to the users. - I have a database with 3 documents created by these users:
docA,docB,docC
All these documents could be viewed by _all_docs view by default
I need to have a maintainable and scalable solution to hide documents.
For example:
a) Documents docA and docC should be available to view by users with roleA only
b) Documents docB and docC should be available to view by users with roleB only
c) Admins could see everything
I have reviewed an official documentation, best practices and other similar topics, but I can't find any scalable solution for this task
First of all in CouchDB, the
_all_docsview is a built-in view that allows you to retrieve a list of all documents in a database. By default, any authenticated user with read access to the database can query the_all_docsview.Also CouchDB doesn't inherently provide a feature for hiding documents, you can implement security measures to control access only for editing documents based on user roles and permissions using
validate_doc_updatefunction at the_designdocumentFor example:
One more poor situation is how to debug these functions in case we have more complex logic.