createRelationTable<T> function
T
createRelationTable<T>({})
Creates a new Table containing TableRelation
with information
about how the tables are joined.
relationFieldName
is the reference name of the table join.
field
is the Column of the table that is used to join the tables.
foreignField
is the Column of the foreign table that is used to join
table.
tableRelation
is the TableRelation
of the table that is used to join
the tables.
Implementation
T createRelationTable<T>({
required String relationFieldName,
required Column field,
required Column foreignField,
TableRelation? tableRelation,
required T Function(
TableRelation foreignTableRelation,
) createTable,
}) {
var relationDefinition = TableRelationEntry(
relationAlias: relationFieldName,
field: field,
foreignField: foreignField,
);
if (tableRelation == null) {
return createTable(TableRelation([relationDefinition]));
}
return createTable(
tableRelation.copyAndAppend(relationDefinition),
);
}