Documents represent database records. Each document is a (in)complete subset of fields contained in a record. Available data types and query mechanisms are determined by the storage in use.
The API was inspired by Django, MongoKit, WTForms, Svarga and several other projects. It was important to KISS (keep it simple, stupid), DRY (do not repeat yourself) and to make the API as abstract as possible so that it did not depend on backends and yet did not get in the way.
A document/query object. Dict-like representation of a document stored in a database. Includes schema declaration, bi-directional validation (outgoing and query), handles relations and has the notion of the saved state, i.e. knows the storage and primary key of the corresponding record.
Returns given query filtered by schema and validators defined for this document.
Deletes the object from the associated storage.
Returns a document instance filled with given data and bound to given storage and key. The instance can be safely saved back using save(). If the concrete subclass defines the structure, then usused fields coming from the storage are hidden from the public API but nevertheless they will be saved back to the database as is.
Returns current primary key (if any) or None.
Saves instance to given storage.
Parameters: |
|
---|
Checks if instance data is valid. This involves a) checking whether all values correspond to the declated structure, and b) running all Validators against the data dictionary.
Raises ValidationError if something is wrong.
Note
if the data dictionary does not contain some items determined by structure or validators, these items are not checked.
Note
The document is checked as is. There are no side effects. That is, if some required values are empty, they will be considered invalid even if default values are defined for them. The save() method, however, fills in the default values before validating.
alias of OneToManyRelation