bknd
Version:
Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.
48 lines (47 loc) • 2.17 kB
TypeScript
import type { Static } from "../../core/utils";
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 * as tbbox from "@sinclair/typebox";
export type ManyToManyRelationConfig = Static<typeof ManyToManyRelation.schema>;
export declare class ManyToManyRelation extends EntityRelation<typeof ManyToManyRelation.schema> {
connectionEntity: Entity;
additionalFields: Field[];
connectionTableMappedName: string;
private em?;
static schema: tbbox.TObject<{
required: tbbox.TOptional<tbbox.TBoolean>;
mappedBy: tbbox.TOptional<tbbox.TString>;
inversedBy: tbbox.TOptional<tbbox.TString>;
connectionTable: tbbox.TOptional<tbbox.TString>;
connectionTableMappedName: tbbox.TOptional<tbbox.TString>;
}>;
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;
}