Field
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
.Default
None
Must have a value assigned.
None
, an empty string, and other falsy values are acceptable.Default
False
If
True
, will store None
. If False
, will store any non-None
default, or remove the field from the backing store.Default
False
The set of other fields that must not be set for this field to be writeable.
Default
None
Define how Python-side code interacts with the stored MongoDB data values.
A Marrow Schema
Transformer
class to use when loading or storing values.Default
FieldTransform()
A Marrow Schema
Validator
class to use when validating values during assignment.Default
Validator()
Automatically assign the default value to the backing store when constructing a new instance or the value is found to be missing on access.
Default
False
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.
Default
True
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
.Default
True
Inlcude (or exclude) this field from the default projection.
Default
None
Permission to read values from this field.
Not internally enforced.
Default
True
Permission to assign values to this field.
Not internally enforced.
Default
True
Allow sorting/ordering on this field.
Not internally enforced.
Default
True
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.
Type
set
Specific operations may be excluded from group-based inclusion, if utilized above.
Type
set
A weak reference to the document the instance is bound to; automatically popualted.
Read-Only
Type
str
Last modified 5yr ago