开发者

How do you get a list of all the _design documents for a given database in CouchDB?

开发者 https://www.devze.com 2022-12-28 07:30 出处:网络
I have searched all over and can\'t figure out how to get a list of all the des开发者_C百科ign documents for a specific database in CouchDB? here is how using a straight HTTP call.

I have searched all over and can't figure out how to get a list of all the des开发者_C百科ign documents for a specific database in CouchDB?


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)
0

精彩评论

暂无评论...
验证码 换一张
取 消