Reputation: 874
I need a get a list of all databases in a Couchdb server inside a view/validation function.
Is there CouchDb predefiend function that i can use it inside function (like emit)?
I know i can do http request to get this , something like :
"http://server/_all_dbs"
but it is realy messy.
Thanks oren.
Upvotes: 8
Views: 12463
Reputation: 302
Couchdb documentation on _all_dbs can be found here
API calls look like: http://server_address:server_port/_all_dbs
Could you be more specific with "messy"? The API response body looks fine to me: an array of db names is what I expect.
Upvotes: 1
Reputation: 113
You have 2 way to list all databases in the CouchDB server
Without Password
curl -X GET http://127.0.0.1:5984/_all_dbs
With Password
curl -X GET http://USER:[email protected]:5984/_all_dbs
Upvotes: 9
Reputation: 7318
I know i can do http request to get this , something like :
but it is realy messy.
You can use jq to make this less messy:
ccurl /all_dbs | jq
(The above uses ccurl to make life easier.)
Upvotes: 4
Reputation: 27971
No, within a view all you have visibility of is the document that you're processing.
Upvotes: 6