Home / Class/ Table Class — drizzle-orm Architecture

Table Class — drizzle-orm Architecture

Architecture documentation for the Table class in table.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  6f4580c8_dbd3_725b_5126_f06988ed43ab["Table"]
  ddbb35ab_7e67_d2b6_96ec_1f37678fcb67["table.ts"]
  6f4580c8_dbd3_725b_5126_f06988ed43ab -->|defined in| ddbb35ab_7e67_d2b6_96ec_1f37678fcb67
  549f9fbd_5034_1f3c_5a57_91382f2f7e26["constructor()"]
  6f4580c8_dbd3_725b_5126_f06988ed43ab -->|method| 549f9fbd_5034_1f3c_5a57_91382f2f7e26

Relationship Graph

Source Code

drizzle-orm/src/table.ts lines 49–118

export class Table<T extends TableConfig = TableConfig> implements SQLWrapper {
	static readonly [entityKind]: string = 'Table';

	declare readonly _: {
		readonly brand: 'Table';
		readonly config: T;
		readonly name: T['name'];
		readonly schema: T['schema'];
		readonly columns: T['columns'];
		readonly inferSelect: InferSelectModel<Table<T>>;
		readonly inferInsert: InferInsertModel<Table<T>>;
	};

	declare readonly $inferSelect: InferSelectModel<Table<T>>;
	declare readonly $inferInsert: InferInsertModel<Table<T>>;

	/** @internal */
	static readonly Symbol = {
		Name: TableName as typeof TableName,
		Schema: Schema as typeof Schema,
		OriginalName: OriginalName as typeof OriginalName,
		Columns: Columns as typeof Columns,
		ExtraConfigColumns: ExtraConfigColumns as typeof ExtraConfigColumns,
		BaseName: BaseName as typeof BaseName,
		IsAlias: IsAlias as typeof IsAlias,
		ExtraConfigBuilder: ExtraConfigBuilder as typeof ExtraConfigBuilder,
	};

	/**
	 * @internal
	 * Can be changed if the table is aliased.
	 */
	[TableName]: string;

	/**
	 * @internal
	 * Used to store the original name of the table, before any aliasing.
	 */
	[OriginalName]: string;

	/** @internal */
	[Schema]: string | undefined;

	/** @internal */
	[Columns]!: T['columns'];

	/** @internal */
	[ExtraConfigColumns]!: Record<string, unknown>;

	/**
	 *  @internal
	 * Used to store the table name before the transformation via the `tableCreator` functions.
	 */
	[BaseName]: string;

	/** @internal */
	[IsAlias] = false;

	/** @internal */
	[IsDrizzleTable] = true;

	/** @internal */
	[ExtraConfigBuilder]: ((self: any) => Record<string, unknown> | unknown[]) | undefined = undefined;

	constructor(name: string, schema: string | undefined, baseName: string) {
		this[TableName] = this[OriginalName] = name;
		this[Schema] = schema;
		this[BaseName] = baseName;
	}
}

Domain

Frequently Asked Questions

What is the Table class?
Table is a class in the drizzle-orm codebase, defined in drizzle-orm/src/table.ts.
Where is Table defined?
Table is defined in drizzle-orm/src/table.ts at line 49.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free