mwg API
    Preparing search index...

    Type Alias MwlTableReference

    MwlTableReference:
        | {
            column: string;
            references: { column: string; table: string };
            table: string;
        }
        | { column: string; oneOf: readonly string[]; table: string }
        | { column: string; references: { node: string }; table: string }

    One declarative cross-table reference: a column of one [table] whose every cell must resolve: against a column of another [table], against an authored node-id namespace (references: { node: 'monster' } checks every cell names an authored [monster] id), or against a closed value set. The declaration names the shape; the contents (which column points where, which set is legal) stay game data in the consuming repository.

    Type Declaration

    • { column: string; references: { column: string; table: string }; table: string }
      • Readonlycolumn: string

        column whose cells must resolve

      • Readonlyreferences: { column: string; table: string }

        the referenced table and the column its values are drawn from

      • Readonlytable: string

        id of the [table] holding the referencing column

    • { column: string; oneOf: readonly string[]; table: string }
      • Readonlycolumn: string

        column whose cells must resolve

      • ReadonlyoneOf: readonly string[]

        the exact closed set the column's cells must belong to

      • Readonlytable: string

        id of the [table] holding the referencing column

    • { column: string; references: { node: string }; table: string }
      • Readonlycolumn: string

        column whose cells must resolve

      • Readonlyreferences: { node: string }

        the authored node-id namespace (a node tag) the column's cells must belong to

      • Readonlytable: string

        id of the [table] holding the referencing column

    import { compile, validateCatalog } from '@datamoc/mwg/mwl';

    const game = compile(
    "[{ tag: 'table', id: 'items', columns: 'id:string', children: [{ tag: 'row', id: 'sword' }] }, { tag: 'table', id: 'recipes', columns: 'ingredient:string', children: [{ tag: 'row', ingredient: 'sword' }] }]",
    );
    const declarations = [{ table: 'recipes', column: 'ingredient', references: { table: 'items', column: 'id' } }];
    console.log(validateCatalog(game, { tableReferences: declarations })); // []