ModelDefinition<TModel extends OrmEntity> class
Runtime description of a generated ORM model.
Generated code registers a ModelDefinition for each @OrmModel() type.
Queries and repositories use the definition to:
- Resolve table/schema metadata.
- Encode models into column maps for mutations.
- Decode result rows into tracked model instances.
Most applications never create definitions manually; they are emitted by the code generator and stored in ModelRegistry.
- Implementers
Constructors
-
ModelDefinition({required String modelName, required String tableName, required List<
FieldDefinition> fields, required ModelCodec<TModel> codec, UntrackedModelEncoder? untrackedToMap, String? schema, List<RelationDefinition> relations = const [], String? softDeleteColumn, ModelAttributesMetadata metadata = const ModelAttributesMetadata(), Map<String, AttributeAccessor> accessors = const {}, Map<String, AttributeMutator> mutators = const {}}) -
const
Properties
-
accessors
→ Map<
String, AttributeAccessor> -
Attribute accessors keyed by column name.
final
-
codec
→ ModelCodec<
TModel> -
Codec for encoding/decoding model instances to/from maps.
final
-
fields
→ List<
FieldDefinition> -
List of all field definitions for this model.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- metadata → ModelAttributesMetadata
-
Metadata controlling attribute behavior (hidden, fillable, etc.).
final
- modelName → String
-
The name of the model class.
final
- modelType → Type
-
Returns the runtime type of the model.
no setter
-
mutators
→ Map<
String, AttributeMutator> -
Attribute mutators keyed by column name.
final
- primaryKeyField → FieldDefinition?
-
Returns the primary key field definition, if one exists.
no setter
-
relations
→ List<
RelationDefinition> -
List of all relation definitions for this model.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- schema → String?
-
Optional database schema name.
final
- softDeleteColumn → String?
-
Column name used for soft deletes, if enabled.
final
- softDeleteField → FieldDefinition?
-
Returns the field definition for the soft delete column, if configured.
no setter
- tableName → String
-
The database table name for this model.
final
- untrackedToMap → UntrackedModelEncoder?
-
Optional encoder for user-defined (untracked) model instances.
final
- usesSoftDeletes → bool
-
Returns true if this model uses soft deletes.
no setter
Methods
-
copyWith(
{String? modelName, String? tableName, String? schema, List< FieldDefinition> ? fields, List<RelationDefinition> ? relations, ModelCodec<TModel> ? codec, UntrackedModelEncoder? untrackedToMap, String? softDeleteColumn, ModelAttributesMetadata? metadata, Map<String, AttributeAccessor> ? accessors, Map<String, AttributeMutator> ? mutators}) → ModelDefinition<TModel> - Creates a copy of this definition with the specified fields replaced.
-
fieldByColumn(
String column) → FieldDefinition? - Finds a field by its database column name.
-
fieldByName(
String name) → FieldDefinition? - Finds a field by its Dart property name.
-
fromMap(
Map< String, Object?> data, {ValueCodecRegistry? registry}) → TModel - Decodes a map to a model instance using the model's codec.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toMap(
covariant dynamic model, {ValueCodecRegistry? registry}) → Map< String, Object?> - Encodes a model instance to a map using the model's codec.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited