tableSchemaOf

tcmts.cli.data_pages.tableSchemaOf · #ea3qegck · term · runs anywhere

The table declared as table in the codebase (its name), with its row type: what writing to it needs.

import type { Codebase } from "#codebase/tcmts/cli/codebase";
import type { TableSchema } from "#codebase/tcmts/core/schema";

export function tableSchemaOf(cb: Codebase, table: string): TableSchema | undefined {
  for (const n of cb.store.names()) {
    const t = n.kind === "term" ? cb.store.getDef(n.hash)?.table : undefined;
    if (t?.name === table) return t;
  }
  return undefined;
}

uses

used by