withRoles method
Implementation
UserQuery withRoles() {
final userRole = Repository<UserRole>(database: database as Database);
final Column? relationColumn = userRole.columns.firstWhere((column) =>
column.relation?.referencedEntity?.tableName == this.tableName);
if (relationColumn != null) {
ColumnRelation relation = ColumnRelation(
referencedColumn: relationColumn.relation?.attributeName,
attributeName: 'roles',
primaryKey: this.primaryKey?.name,
relationType: RelationType.OneToMany,
referencedEntity: Entity.getEntityDefinition(
AnnotationReflectable.reflectType(UserRole) as ClassMirror),
referencedEntityColumns: Entity.getEntityColumns(
AnnotationReflectable.reflectType(UserRole) as ClassMirror,
false));
this.relations.add(relation);
}
return this;
}