couchdb how to list all users on db?
curl gets all users as documents, grep extracts documents _id
, sed strips org.couchdb.user:
prefix and sort removes duplicates that comes from view result:
curl -s http://localhost:5984/_users/_all_docs | grep -o 'org.couchdb.user:[[:alnum:]]\+' | sed -n -e 's/org.couchdb.user:\(.*\)/\1/p' | sort -u
Note, that since 1.2.0 release if you had fixed Admin Party on server, you need to pass CouchDB admin credentials to make such requests for _users
database.
Use _all_docs
, the following command lists all docs info of a specific database, just specify database name then you are done:
curl -X GET http://localhost:5984/<db_name>/_all_docs
Then replace <db_name>
with _users
, and use port 5986 since _users
is a system table under port 5986:
curl -X GET http://localhost:5986/_users/_all_docs