genericRelationsModel function

Model genericRelationsModel({
  1. required String firstModelId,
  2. required String secondModelId,
  3. String? firstModelName,
  4. String? secondModelName,
  5. bool withPrimaryKey = true,
})

Implementation

Model genericRelationsModel({
  required String firstModelId,
  required String secondModelId,
  String? firstModelName,
  String? secondModelName,
  bool withPrimaryKey = true,
}) {
  final String firstName = firstModelName ?? firstModelId.toUpperCase();
  final String secondName = secondModelName ?? secondModelId.toUpperCase();

  return Model(
    name: '$firstName : $secondName relations',
    icon: IconPackNames.mdi_relation_many_to_many,
    fields: [
      [
        if (withPrimaryKey) IdField(),
        IdField(id: firstModelId, name: firstName),
        IdField(id: secondModelId, name: secondName),
      ],
    ],
  );
}