Just a test of syntaxhighlighter in blogger
Friday, February 27, 2009
This is just a test of syntaxhighlighter.
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")
# to make a view permanent do this
from couchdb.design import ViewDefinition
ViewDefinition.sync_many(db, [Person.by_name])
Person(name = "batok", age = 48).store(db)
Person(name = "rgalvan", age = 47).store(db)
Person(name = "robert", age = 30).store(db)
for person in Person.by_name( db, limit = 3):
print person.name, person.age