I have searched all over and can't figure out how to get a list of all the design documents for a specific database in CouchDB?
views:
38answers:
1
+2
A:
here is how using a straight HTTP call.
http://localhost:5984/mydatabase/_all_docs?startkey=%22_design%22&endkey=%22_design0%22
here is how to get all _design documents and their views for all databases using couchdbkit
#!/usr/bin/env python
from couchdbkit import *
server = Server()
dbs = server.all_dbs()
for dbname in dbs:
db = server.get_or_create_db(dbname)
result = db.all_docs(startkey='_design', endkey='_design0')
for doc in result.all():
designdoc = db.get(doc['id'])
if 'views' in designdoc:
for view in designdoc['views']:
print '%s/%s/_view/%s' % (dbname, designdoc['_id'], view)
fuzzy lollipop
2010-04-28 22:52:51
Awesome! You may want to check for _design%2F because _designblah is not a design doc however in practice it probably doesn't matter.
jhs
2010-04-29 05:43:09
Meant to say: `_design/` through `_design0`. And maybe leave a comment in your source to remind you that '0' comes after '/'
jhs
2010-04-29 05:51:05
I used firebug to figure out how Futon does the query
fuzzy lollipop
2010-04-29 06:27:09