couchdb.schema.Document

Package couchdb :: Module schema :: Class Document |

# Class Document

    object --+
             |
        Schema --+
                 |
                Document

Nested Classes
| __metaclass__

Instance Methods
__init__(self, id=None, **values) x.__init__(...) initializes x; see x.__class__.__doc__ for signature |
__repr__(self) repr(x) |
items(self) Return the fields as a list of `(name, value)` tuples. |
store(self, db) Store the document in the given database. |
Inherited from `Schema`: `__delitem__`, `__getitem__`, `__iter__`, `__len__`, `__setitem__`, `get`, `setdefault`, `unwrap` Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Class Methods
load(cls, db, id) Load a specific document from the given database. |
query(cls, db, map_fun, reduce_fun, language=`'``javascript``'`, **options) Execute a CouchDB temporary view and map the result values back to objects of this schema. |
view(cls, db, viewname, **options) Execute a CouchDB named view and map the result values back to objects of this schema. |
Inherited from `Schema`: `build`, `wrap`

Properties
| id The document ID
basestring | rev The document revision.
Inherited from `object`: `__class__`

Method Details

### __init__(self, id=None, **values) (Constructor) |
x.__init__(...) initializes x; see x.__class__.__doc__ for signature Overrides: object.__init__ (inherited documentation)

### __repr__(self) (Representation operator) |
repr(x) Overrides: object.__repr__ (inherited documentation)

### items(self) |
Return the fields as a list of `(name, value)` tuples. This method is provided to enable easy conversion to native dictionary objects, for example to allow use of schema.Document instances with client.Database.update.
    >>> class Post(Document):
    ...     title = TextField()
    ...     author = TextField()
    >>> post = Post(id='foo-bar', title='Foo bar', author='Joe')
    >>> sorted(post.items())
    [('_id', 'foo-bar'), ('author', u'Joe'), ('title', u'Foo bar')]
Returns: a list of `(name, value)` tuples

### load(cls, db, id) Class Method |
Load a specific document from the given database. Parameters: `db` - the Database object to retrieve the document from `id` - the document ID Returns: the Document instance, or `None` if no document with the given ID was found

### query(cls, db, map_fun, reduce_fun, language=`'``javascript``'`, **options) Class Method |
Execute a CouchDB temporary view and map the result values back to objects of this schema. Note that by default, any properties of the document that are not included in the values of the view will be treated as if they were missing from the document. If you want to load the full document for every row, set the `include_docs` option to `True`.

### view(cls, db, viewname, **options) Class Method |
Execute a CouchDB named view and map the result values back to objects of this schema. Note that by default, any properties of the document that are not included in the values of the view will be treated as if they were missing from the document. If you want to load the full document for every row, set the `include_docs` option to `True`.

Property Details

### id The document ID Get Method: _get_id(self) Set Method: _set_id(self, value)

### rev The document revision. Get Method: unreachable.rev(self) - The document revision. Type: basestring