Created
March 26, 2012 22:50
-
-
Save johnzablocki/2210390 to your computer and use it in GitHub Desktop.
Couchbase Python Client Library View REST API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from couchbase.rest_client import RestConnection | |
doc = """ | |
{ | |
"_id": "_design/breweries", | |
"views": { | |
"all_breweries": { | |
"map": "function(doc) { if (doc.type == 'beer') emit(null, doc) }" | |
} | |
} | |
} | |
""" | |
print doc | |
def main(): | |
server_info = { "ip" : "127.0.0.1", "port" : 8092, "username" : "", "password" : "", "couchApiBase" : "http://127.0.0.1:8092/" } | |
rest = RestConnection(server_info) | |
print "** create_design_doc **" | |
print rest.create_design_doc("default", "breweries", doc) | |
print "** get_design_doc **" | |
print rest.get_design_doc("default", "breweries") | |
print "** get_view **" | |
print rest.get_view("default", "breweries", "all_breweries") | |
print rest.delete_design_doc("default", "breweries") | |
print "** delete_design_doc **" | |
print "** view_results **" | |
print rest.view_results("default", "beers", "beers_by_name", {"start_key" : "T"}, limit=2) | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment