Parameters: |
|
---|
The general validator is called after the field’s validator, but before either of the wrap/unwrap versions. The validator should raise a BadValueException if it fails, but if it returns False the field will raise an exception with a generic message.
Is this a sequence? used by elemMatch
Unicode Strings. unicode is used to wrap and unwrap values, and any subclass of basestring is an acceptable input
Parameters: |
|
---|
Base class for numeric fields
Parameters: |
|
---|
Subclass of NumberField for int
Parameters: |
|
---|
Subclass of NumberField for float
Parameters: |
|
---|
Represents a field which is a tuple of a fixed size with specific types for each element in the field.
Examples TupleField(IntField(), BoolField()) would accept [19, False] as a value for both wrapping and unwrapping.
Parameters: |
---|
Represents a single value out of a list of possible values, all of the same type. == is used for comparison
Example: EnumField(IntField(), 4, 6, 7) would accept anything in (4, 6, 7) as a value. It would not accept 5.
Parameters: |
|
---|
pymongo Object ID object. Currently this is probably too strict. A string version of an ObjectId should also be acceptable
Helper method to create a new ObjectId
A field that passes through whatever is set with no validation. Useful for free-form objects
Parameters: |
|
---|
The general validator is called after the field’s validator, but before either of the wrap/unwrap versions. The validator should raise a BadValueException if it fails, but if it returns False the field will raise an exception with a generic message.
Field for datetime objects.
Parameters: |
|
---|
A shortcut field for creation time. It sets the current date and time when it enters the database and then doesn’t update on further saves.
If you’ve used the Django ORM, this is the equivalent of auto_now_add
Parameters: | tz_aware – If this is True, the value will be returned in the local time of the session. It is always saved in UTC |
---|
A shortcut field for modified time. It sets the current date and time when it enters the database and then updates when the document is saved or updated
If you’ve used the Django ORM, this is the equivalent of auto_now
Parameters: | tz_aware – If this is True, the value will be returned in the local time of the session. It is always saved in UTC |
---|
Field representing a python list.
Parameters: |
|
---|
Field representing a python set.
Parameters: |
|
---|
Stores String to value_type Dictionaries. For non-string keys use KVField. Strings also must obey the mongo key rules (no . or $)
Parameters: | value_type – the Field type to use for the values |
---|
Like a DictField, except it allows arbitrary keys. The DB Format for a KVField is [ { 'k' : key, 'v' : value }, ...]. Queries on keys and values. can be done with .k and .v
Parameters: |
|
---|
A ref field wraps a mongo DBReference. It DOES NOT currently handle saving the referenced object or updates to it, but it can handle auto-loading.
Parameters: |
|
---|
Dereference a pymongo “DBRef” to this field’s underlying type
Used to create an attribute which will auto-dereference a RefField or SRefField.
Example:
employer_ref = SRefField(Employer)
employer = employer_ref.rel()
A Simple RefField (SRefField) looks like an ObjectIdField in the database, but acts like a mongo DBRef. It uses the passed in type to determine where to look for the object (and assumes the current database).
Dereference an ObjectID to this field’s underlying type
Used to create an attribute which will auto-dereference a RefField or SRefField.
Example:
employer_ref = SRefField(Employer)
employer = employer_ref.rel()
A computed field is generated based on an object’s other values. It will generally be created with the @computed_field decorator, but can be passed an arbitrary function.
The function should take a dict which will contains keys with the names of the dependencies mapped to their values.
The computed value is recalculated every the field is accessed unless the one_time field is set to True.
Example:
>>> class SomeDoc(Document):
... @computed_field
... def last_modified(obj):
... return datetime.datetime.utcnow()
Warning
The computed field interacts in an undefined way with partially loaded documents right now. If using this class watch out for strange behaviour.
Parameters: |
|
---|