withDataValues method

DataValueSetQuery withDataValues()

Implementation

DataValueSetQuery withDataValues() {
  final dataValue = Repository<DataValue>(database: database as Database);

  final Column? relationColumn = dataValue.columns.firstWhere((column) {
    return column.relation?.referencedEntity?.tableName == this.tableName;
  });

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

    this.relations.add(relation);
  }

  return this;
}