DatumFieldSpec<E, V> class

A full runtime descriptor for one serialized field of entity E with Dart value type V.

Declared once per field as static final (the codec/getter closures rule out const), the same declare-once pattern as MemoizedRelations:

abstract final class TaskFields {
  static final title = DatumFieldSpec<Task, String>('title', getter: (t) => t.title);
  static final priority = DatumFieldSpec<Task, int>('priority',
      getter: (t) => t.priority, defaultValue: 0, renamedFrom: 'prio');
}

// Everything DatumQueryField offers still works:
final query = DatumQueryBuilder<Task>().whereField(TaskFields.priority, isGreaterThan: 2).build();
Inheritance

Constructors

DatumFieldSpec(String name, {DatumFieldGetter<E, V>? getter, DatumFieldCodec<V>? codec, String? sqlType, V? defaultValue, String? renamedFrom, DatumCoreRole? coreRole})

Properties

codec DatumFieldCodec<V>
Converts between V and the persisted representation.
final
coreRole DatumCoreRole?
Marks one of the six standard sync fields (set by datumCoreFieldSpecs); null for payload fields. DatumSchema.diffOf / propsOf use it to separate payload from sync metadata.
final
defaultValue → V?
Backfill value auto-migration uses when adding this column to existing rows. Required (or isNullable) for a field to be auto-addable.
final
getter DatumFieldGetter<E, V>?
Extracts this field's value from an entity; required for DatumSchema.toMap delegation, optional otherwise.
final
hashCode int
The hash code for this object.
no setterinherited
isNotNull Filter
field IS NOT NULL
no setterinherited
isNull Filter
field IS NULL
no setterinherited
isNullable bool
Whether V admits null.
no setter
name String
The serialized field name (map key / column), supporting dot notation.
finalinherited
renamedFrom String?
The previous serialized name of this field. Auto-migration treats a store that has renamedFrom but not name as a rename instead of a drop + add (which would lose data).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sqlType String?
Explicit SQL column type (e.g. 'TEXT'); wins over resolveSqlType's derivation.
final
valueType Type
The Dart value type of this field.
no setter

Methods

decode(Object? raw) → V
Decodes raw with codec, wrapping any failure in a SchemaReadException that names this field.
encode(V value) Object?
Encodes value with codec.
equalTo(V value) Filter
field == value
inherited
greaterThan(V value) Filter
field > value
inherited
greaterThanOrEqual(V value) Filter
field >= value
inherited
isIn(List<V> values) Filter
field IN values
inherited
isNotIn(List<V> values) Filter
field NOT IN values
inherited
lessThan(V value) Filter
field < value
inherited
lessThanOrEqual(V value) Filter
field <= value
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notEqualTo(V value) Filter
field != value
inherited
resolveSqlType({SqlDialect dialect = SqlDialect.sqlite}) String
The SQL column type for this field: sqlType when given, else derived from V (int→INTEGER, double→REAL / DOUBLE PRECISION, num→NUMERIC, bool→BOOLEAN, String/DateTime/Uri/BigInt→TEXT, Duration→INTEGER).
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited