Kristian
Kristian

Reputation: 21800

couchdb how to list all users on db?

I'm trying to determine what users have been created.

is there a curl command in couch to list all existing couchdb users?

if so what is it is that curl call?

Upvotes: 5

Views: 7452

Answers (2)

coderz
coderz

Reputation: 4989

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

Upvotes: 7

Kxepal
Kxepal

Reputation: 4679

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.

Upvotes: 7

Related Questions