Document object that map a CouchDB Document. It allow you to map statically a document by providing fields like you do with any ORM or dynamically. Ie unknown fields are loaded as object property that you can edit, datetime in iso3339 format are automatically translated in python types (date, time & datetime) and decimal too.
Example of documentass
from simplecouchdb.schema import *
class MyDocument(Document):
mystring = StringProperty()
myotherstring = unicode() # just use python types
Fields of a documents can be accessed as property or key of dict. These are similar : value = instance.key or value = instance['key'].
To delete a property simply do del instance[key'] or delattr(instance, key)
Methods
- save()¶
Save document in database.
Params db: simplecouchdb.core.Database instance
- validate(required=True)¶
- validate a document
- items()¶
- return list of items
- __len__()¶
- get number of properties
- __iter__()¶
- iter document instance properties
- __setitem__(key, value)¶
- add a property
- __getitem__(key)¶
- get property value
- __delitem__(key)¶
- delete a property
- __setattr__(key, value)¶
- __getattr__(key)¶
- get property value
- __delattr__(key)¶
- delete property
- properties()¶
- dynamic_properties()¶