withActions method

ProgramRuleQuery withActions()

Implementation

ProgramRuleQuery withActions() {
  final programRuleAction =
      Repository<ProgramRuleAction>(database: database as Database);
  final Column? relationColumn = programRuleAction.columns.firstWhere(
      (column) =>
          column.relation?.referencedEntity?.tableName == this.tableName);

  if (relationColumn != null) {
    ColumnRelation relation = ColumnRelation(
        referencedColumn: relationColumn.relation?.attributeName,
        attributeName: 'programRuleActions',
        primaryKey: this.primaryKey?.name,
        relationType: RelationType.OneToMany,
        referencedEntity: Entity.getEntityDefinition(
            AnnotationReflectable.reflectType(ProgramRuleAction)
                as ClassMirror),
        referencedEntityColumns: Entity.getEntityColumns(
            AnnotationReflectable.reflectType(ProgramRuleAction)
                as ClassMirror,
            false));
    this.relations.add(relation);
  }

  return this;
}