name property

String get name

Returns the inferred pivot table name for T and U.

The name is generated by concatenating the type names and converting the result to snake_case.

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

Implementation

String get name {
  final typeName = "$T$U";
  final snakeCase = typeName.replaceAllMapped(RegExp(r'(?<=[a-z])(?=[A-Z])'), (match) => '_');
  return snakeCase.toLowerCase();
}