MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / relationBuilder

Function relationBuilder

packages/core/fumadb/src/schema/create.ts:540–568  ·  view source on GitHub ↗
(tables: Tables, k: K)

Source from the content-addressed store, hash-verified

538}
539
540function relationBuilder<
541 Tables extends Record<string, AnyTable>,
542 K extends keyof Tables,
543>(tables: Tables, k: K): RelationBuilder<Tables, K> {
544 const referencer = tables[k];
545
546 return {
547 one(another, ...on) {
548 if (on.length > 0) {
549 const init = new ExplicitRelationInit(
550 "one",
551 tables[another],
552 referencer
553 );
554 init.on = on as [string, string][];
555 return init;
556 }
557
558 return new ImplicitRelationInit(
559 "one",
560 tables[another],
561 referencer
562 ) as any;
563 },
564 many(another) {
565 return new ImplicitRelationInit("many", tables[another], referencer);
566 },
567 };
568}
569
570export function table<Columns extends Record<string, AnyColumn>>(
571 name: string | Partial<NameVariants>,

Callers 1

setRelationsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected