Skip to content

Instantly share code, notes, and snippets.

@batok
Created November 19, 2008 17:12
Show Gist options
  • Save batok/26593 to your computer and use it in GitHub Desktop.
Save batok/26593 to your computer and use it in GitHub Desktop.
from couchdb.schema import Document, View, IntegerField, TextField
from couchdb import Database
map_fun = """
function(doc){
emit(doc.name, doc.age);
}
"""
class Person(Document):
name = TextField()
age = IntegerField()
by_name = View('people', map_fun)
db = Database("http://127.0.0.1:5984/borrame")
print Person.by_name
print Person.by_name.map_fun
#Person(name = "batok", age = 48).store(db)
#Person(name = "pochas", age = 47).store(db)
#Person(name = "robert", age = 30).store(db)
view = Person.by_name( db, count = 3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment