refactor: update id handling for media entity

Revised `id` and `entity_id` types to support both string and number for flexibility. Adjusted `PolymorphicRelation` to use `PrimaryFieldType` for improved type safety and maintainability.
This commit is contained in:
dswbx
2025-09-19 11:28:51 +02:00
parent 91120091a3
commit 059becbf09
3 changed files with 5 additions and 6 deletions

View File

@@ -6,6 +6,7 @@ import { EntityRelation, type KyselyJsonFrom, type KyselyQueryBuilder } from "./
import { EntityRelationAnchor } from "./EntityRelationAnchor";
import { type RelationType, RelationTypes } from "./relation-types";
import { s } from "bknd/utils";
import type { PrimaryFieldType } from "bknd";
export type PolymorphicRelationConfig = s.Static<typeof PolymorphicRelation.schema>;
@@ -70,7 +71,7 @@ export class PolymorphicRelation extends EntityRelation<typeof PolymorphicRelati
.groupBy(groupBy);
}
override getReferenceQuery(entity: Entity, id: number): Partial<RepoQuery> {
override getReferenceQuery(entity: Entity, id: PrimaryFieldType): Partial<RepoQuery> {
const info = this.queryInfo(entity);
return {