Database / CouchDB Interview Questions
What is a CouchDB _security object and how do you configure roles and members?
The _security object is a special document stored at /db/_security. It defines which users and roles can act as admins (write design documents, change security) or members (read and write regular documents) for that specific database. Every database has one.
{
"admins": {
"names": ["alice", "bob"],
"roles": ["db_admin_role"]
},
"members": {
"names": ["charlie"],
"roles": ["viewer", "editor"]
}
}
# Set the _security object
curl -X PUT http://admin:pass@localhost:5984/mydb/_security \
-H "Content-Type: application/json" \
-d '{
"admins": { "names": ["alice"], "roles": ["db_admin_role"] },
"members": { "names": [], "roles": ["editor","viewer"] }
}'
# Read the current _security object
curl http://admin:pass@localhost:5984/mydb/_security
Key behaviors:
- If the
memberslist is empty (both names and roles), the database is readable by any authenticated user or even anonymously (public database). - Server admins bypass the
_securityobject entirely — they always have full access to every database. - Roles are arbitrary strings. They are assigned to users in the
_usersdatabase under therolesarray in the user document. CouchDB does not provide a built-in role management UI; roles are managed by updating user documents. - Only server admins and database admins can modify the
_securityobject.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
