Home / Function/ gelTableWithSchema() — drizzle-orm Function Reference

gelTableWithSchema() — drizzle-orm Function Reference

Architecture documentation for the gelTableWithSchema() function in table.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  e52caf0d_6511_67ab_71ab_401ba052d941["gelTableWithSchema()"]
  cbe7af57_41be_454d_306f_02d0e6f81949["table.ts"]
  e52caf0d_6511_67ab_71ab_401ba052d941 -->|defined in| cbe7af57_41be_454d_306f_02d0e6f81949
  7b24d348_515e_8ca0_dc7c_1010e8553868["gelTable()"]
  7b24d348_515e_8ca0_dc7c_1010e8553868 -->|calls| e52caf0d_6511_67ab_71ab_401ba052d941
  72658dbf_d6ad_e4f0_60d2_1375a785226f["gelTableCreator()"]
  72658dbf_d6ad_e4f0_60d2_1375a785226f -->|calls| e52caf0d_6511_67ab_71ab_401ba052d941
  d668c247_19c9_54b3_c1cf_4b73bfa42963["getGelColumnBuilders()"]
  e52caf0d_6511_67ab_71ab_401ba052d941 -->|calls| d668c247_19c9_54b3_c1cf_4b73bfa42963
  style e52caf0d_6511_67ab_71ab_401ba052d941 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-orm/src/gel-core/table.ts lines 73–141

export function gelTableWithSchema<
	TTableName extends string,
	TSchemaName extends string | undefined,
	TColumnsMap extends Record<string, GelColumnBuilderBase>,
>(
	name: TTableName,
	columns: TColumnsMap | ((columnTypes: GelColumnsBuilders) => TColumnsMap),
	extraConfig:
		| ((
			self: BuildExtraConfigColumns<TTableName, TColumnsMap, 'gel'>,
		) => GelTableExtraConfig | GelTableExtraConfigValue[])
		| undefined,
	schema: TSchemaName,
	baseName = name,
): GelTableWithColumns<{
	name: TTableName;
	schema: TSchemaName;
	columns: BuildColumns<TTableName, TColumnsMap, 'gel'>;
	dialect: 'gel';
}> {
	const rawTable = new GelTable<{
		name: TTableName;
		schema: TSchemaName;
		columns: BuildColumns<TTableName, TColumnsMap, 'gel'>;
		dialect: 'gel';
	}>(name, schema, baseName);

	const parsedColumns: TColumnsMap = typeof columns === 'function' ? columns(getGelColumnBuilders()) : columns;

	const builtColumns = Object.fromEntries(
		Object.entries(parsedColumns).map(([name, colBuilderBase]) => {
			const colBuilder = colBuilderBase as GelColumnBuilder;
			colBuilder.setName(name);
			const column = colBuilder.build(rawTable);
			rawTable[InlineForeignKeys].push(...colBuilder.buildForeignKeys(column, rawTable));
			return [name, column];
		}),
	) as unknown as BuildColumns<TTableName, TColumnsMap, 'gel'>;

	const builtColumnsForExtraConfig = Object.fromEntries(
		Object.entries(parsedColumns).map(([name, colBuilderBase]) => {
			const colBuilder = colBuilderBase as GelColumnBuilder;
			colBuilder.setName(name);
			const column = colBuilder.buildExtraConfigColumn(rawTable);
			return [name, column];
		}),
	) as unknown as BuildExtraConfigColumns<TTableName, TColumnsMap, 'gel'>;

	const table = Object.assign(rawTable, builtColumns);

	table[Table.Symbol.Columns] = builtColumns;
	table[Table.Symbol.ExtraConfigColumns] = builtColumnsForExtraConfig;

	if (extraConfig) {
		table[GelTable.Symbol.ExtraConfigBuilder] = extraConfig as any;
	}

	return Object.assign(table, {
		enableRLS: () => {
			table[GelTable.Symbol.EnableRLS] = true;
			return table as GelTableWithColumns<{
				name: TTableName;
				schema: TSchemaName;
				columns: BuildColumns<TTableName, TColumnsMap, 'gel'>;
				dialect: 'gel';
			}>;
		},
	});
}

Domain

Subdomains

Frequently Asked Questions

What does gelTableWithSchema() do?
gelTableWithSchema() is a function in the drizzle-orm codebase, defined in drizzle-orm/src/gel-core/table.ts.
Where is gelTableWithSchema() defined?
gelTableWithSchema() is defined in drizzle-orm/src/gel-core/table.ts at line 73.
What does gelTableWithSchema() call?
gelTableWithSchema() calls 1 function(s): getGelColumnBuilders.
What calls gelTableWithSchema()?
gelTableWithSchema() is called by 2 function(s): gelTable, gelTableCreator.

Analyze Your Own Codebase

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

Try Supermodel Free