UNPKG

bknd

Version:

Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.

85 lines (84 loc) 3.75 kB
import type { ExpressionBuilder } from "kysely"; import { Entity, type EntityManager } from "../entities"; import { type Field } from "../fields"; import type { RepoQuery } from "../server/query"; import { EntityRelation, type KyselyQueryBuilder } from "./EntityRelation"; import { EntityRelationAnchor } from "./EntityRelationAnchor"; import { RelationField } from "./RelationField"; import { type RelationType } from "./relation-types"; import { s } from "bknd/utils"; export type ManyToManyRelationConfig = s.Static<typeof ManyToManyRelation.schema>; export declare class ManyToManyRelation extends EntityRelation<typeof ManyToManyRelation.schema> { connectionEntity: Entity; additionalFields: Field[]; connectionTableMappedName: string; private em?; static schema: s.ObjectSchema<{ readonly mappedBy: { default?: any; maxLength?: number | undefined; minLength?: number | undefined; pattern?: (string | RegExp) | undefined; format?: string | undefined; enum?: (readonly any[] | any[]) | undefined; const?: any; } & s.Schema<s.ISchemaOptions, string | undefined, string | undefined>; readonly inversedBy: { default?: any; maxLength?: number | undefined; minLength?: number | undefined; pattern?: (string | RegExp) | undefined; format?: string | undefined; enum?: (readonly any[] | any[]) | undefined; const?: any; } & s.Schema<s.ISchemaOptions, string | undefined, string | undefined>; readonly required: { default?: any; enum?: (readonly any[] | any[]) | undefined; const?: any; } & s.Schema<s.ISchemaOptions, boolean | undefined, boolean | undefined>; readonly connectionTable: { default?: any; maxLength?: number | undefined; minLength?: number | undefined; pattern?: (string | RegExp) | undefined; format?: string | undefined; enum?: (readonly any[] | any[]) | undefined; const?: any; } & s.Schema<s.ISchemaOptions, string | undefined, string | undefined>; readonly connectionTableMappedName: { default?: any; maxLength?: number | undefined; minLength?: number | undefined; pattern?: (string | RegExp) | undefined; format?: string | undefined; enum?: (readonly any[] | any[]) | undefined; const?: any; } & s.Schema<s.ISchemaOptions, string | undefined, string | undefined>; }, s.Merge<s.IObjectOptions & { additionalProperties: false; }>>; constructor(source: Entity, target: Entity, config?: ManyToManyRelationConfig, additionalFields?: Field[]); static defaultConnectionTable(source: Entity, target: Entity): string; type(): RelationType; /** * Many to many is always listable in both directions */ isListableFor(): boolean; getField(entity: Entity): RelationField; protected getQueryInfo(entity: Entity): { other: EntityRelationAnchor; join: readonly [string, `${string}.${string}`, string]; entityRef: string; selfRef: string; otherRef: string; groupBy: string; }; getReferenceQuery(entity: Entity, id: number): Partial<RepoQuery>; buildJoin(entity: Entity, qb: KyselyQueryBuilder): import("kysely").SelectQueryBuilder<any, any, any>; buildWith(entity: Entity): (eb: ExpressionBuilder<any, any>) => import("kysely").SelectQueryBuilder<any, any, { [x: string]: any; }>; initialize(em: EntityManager<any>): void; getName(): string; }