A Field
represents a data types storable within MongoDB and the associated machinery for access, querying, and manipulation. It is the common base class for almost all field types and can be used standalone to represent a "dynamic" field.
from marrow.mongo import Field
marrow.schema:
Attribute
The database-side name of the field, stored internally as the metadata property __name__
.
Default calculated when assigned as a class attribute from the name given to the Field
instance during class construction.
The default value to utilize if the field is missing from the backing store. You may assign a callback routine returning a value to utilize instead.
The permitted set of values as a sequence; may be static or a dynamic, argumentless callback routine as per default
.
DefaultNone
Must have a value assigned. None
, an empty string, and other falsy values are acceptable.
DefaultFalse
If True
, will store None
. If False
, will store any non-None
default, or remove the field from the backing store.
DefaultFalse
The set of other fields that must not be set for this field to be writeable.
DefaultNone
Define how Python-side code interacts with the stored MongoDB data values.
A Marrow Schema Transformer
class to use when loading or storing values.
DefaultFieldTransform()
A Marrow Schema Validator
class to use when validating values during assignment.
DefaultValidator()
Automatically assign the default value to the backing store when constructing a new instance or the value is found to be missing on access.
DefaultFalse
These are either argumentless callback routines returning, or simply the constant values:
None
Interpreted as "no opinion", with the fallback being to deny or exclude.
False
(or falsy)
Explicitly forbid, deny, or exclude.
True
(or truthy)
Explicitly allow or include.
These are used to restrict or define security-like behaviours.
Permit this field to be populated through positional assignment during instantiation of its containing class.
DefaultTrue
Include this field in the programmers' representation, primarily utilized for REPL shells, logging, tracebacks, and other diagnostic purposes.
Protect sensitive fields from accidental exposure by assigning False
.
DefaultTrue
Inlcude (or exclude) this field from the default projection.
DefaultNone
Permission to read values from this field.
Not internally enforced.
DefaultTrue
Permission to assign values to this field.
Not internally enforced.
DefaultTrue
Allow sorting/ordering on this field.
Not internally enforced.
DefaultTrue
Class-level metadata attributes meant for use when subclassing.
The database-side name of this field instance.
Read-Only
The permissable MongoDB filter and update operators, or hash-prefixed groups of operations.
Typeset
Specific operations may be excluded from group-based inclusion, if utilized above.
Typeset
A weak reference to the document the instance is bound to; automatically popualted.
Read-Only
The MongoDB stored datatype, as defined by the $type
operator.
Typestr