Skip to content

Latest commit

 

History

History
32 lines (24 loc) · 533 Bytes

table-introspect-api.md

File metadata and controls

32 lines (24 loc) · 533 Bytes

Table introspect API

Get table information

import { pgTable, getTableConfig } from 'drizzle-orm/pg-core';

const table = pgTable(...);

const {
  columns,
  indexes,
  foreignKeys,
  checks,
  primaryKeys,
  name,
  schema,
} = getTableConfig(table);

Get table columns map

import { pgTable, getTableColumns } from 'drizzle-orm/pg-core';

const table = pgTable('table', {
  id: integer('id').primaryKey(),
  name: text('name'),
});

const columns/*: { id: ..., name: ... } */ = getTableColumns(table);