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?
Couchdb does not have the concept of collections. However, you can achieve similar results using type identifiers on your documents in conjunction with Couchdb views. When you save a document in Couchdb add a field that specifies the type.
CouchDB is a document storage NoSQL database. It provides the facility of storing documents with unique names, and it also provides an API called RESTful HTTP API for reading and updating (add, edit, delete) database documents. In CouchDB, documents are the primary unit of data and they also include metadata.
2. /{db}/_all_docs. Executes the built-in _all_docs view, returning all of the documents in the database.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With