withAuthorities method

UserQuery withAuthorities()

Implementation

UserQuery withAuthorities() {
  final userAuthority =
      Repository<UserAuthority>(database: database as Database);
  final Column? relationColumn = userAuthority.columns.firstWhere((column) =>
      column.relation?.referencedEntity?.tableName == this.tableName);

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

  return this;
}