PivotTable<T extends Model, U extends Model> class abstract

Base type for many-to-many pivot table definitions.

A PivotTable describes the intermediate table used to connect two model types in a belongsToMany relationship. It defines the pivot table name, column schema, and migration behavior for supported database disks.

The generic types T and U represent the two related model types.

Example:

class UserRolePivot extends PivotTable<User, Role> {
  @override
  late final Map<String, String> columnDefinitions = {
    'user_id': 'INTEGER NOT NULL',
    'role_id': 'INTEGER NOT NULL',
  };
}

final pivot = UserRolePivot();
print(pivot.name); // user_role
Implementers

Constructors

PivotTable()

Properties

columnDefinitions Map<String, String>
Column definitions specific to the pivot relationship.
latefinal
createdAt DateTime?
Timestamp indicating when the pivot record was created.
getter/setter pair
disk DatabaseDisk
Storage backend used by this pivot table.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
id int?
Primary key value for the pivot record, when applicable.
getter/setter pair
name String
Returns the inferred pivot table name for T and U.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
updatedAt DateTime?
Timestamp indicating when the pivot record was last updated.
getter/setter pair

Methods

migrate({DatabaseDisk disk = Model.defaultDisk}) Future<void>
Migrates the pivot table schema for the selected disk.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Serializes the pivot record into a JSON-compatible map.
toMetaJson() Map<String, dynamic>
Serializes the pivot record into a metadata-oriented JSON map.
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

defaultColumnDefinitions Map<String, String>
Default columns applied to all pivot tables.
getter/setter pair