MCPcopy
hub / github.com/remix-run/remix / resolveTableColumns

Function resolveTableColumns

packages/data-table/src/lib/table.ts:789–818  ·  view source on GitHub ↗
(
  tableName: string,
  columns: columns,
)

Source from the content-addressed store, hash-verified

787}
788
789function resolveTableColumns<columns extends TableColumnsDefinition>(
790 tableName: string,
791 columns: columns,
792): { [column in keyof columns & string]: ColumnDefinition } {
793 let columnDefinitions: Record<string, ColumnDefinition> = {}
794
795 for (let columnName in columns) {
796 if (!Object.prototype.hasOwnProperty.call(columns, columnName)) {
797 continue
798 }
799
800 let column = columns[columnName]
801
802 if (!(column instanceof ColumnBuilder)) {
803 throw new Error(
804 'Invalid column "' +
805 columnName +
806 '" for table "' +
807 tableName +
808 '". Expected a column(...) builder',
809 )
810 }
811
812 columnDefinitions[columnName] = column.build()
813 }
814
815 return Object.freeze(columnDefinitions) as {
816 [column in keyof columns & string]: ColumnDefinition
817 }
818}
819
820/**
821 * Defines a one-to-many relation from `source` to `target`.

Callers 1

tableFunction · 0.85

Calls 1

buildMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…