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

introspectGel() — drizzle-orm Function Reference

Architecture documentation for the introspectGel() function in introspect.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  395c56cc_0c49_0b4c_347d_abe47b81589f["introspectGel()"]
  c2c22050_0d5c_404e_2b18_5934c728a89c["introspect.ts"]
  395c56cc_0c49_0b4c_347d_abe47b81589f -->|defined in| c2c22050_0d5c_404e_2b18_5934c728a89c
  db0c397a_220a_c404_bea0_7813784bf108["update()"]
  395c56cc_0c49_0b4c_347d_abe47b81589f -->|calls| db0c397a_220a_c404_bea0_7813784bf108
  d34d3e87_b168_fea6_ac14_fef2ffdc1654["relationsToTypeScript()"]
  395c56cc_0c49_0b4c_347d_abe47b81589f -->|calls| d34d3e87_b168_fea6_ac14_fef2ffdc1654
  3f325b6b_14df_fa20_c5d7_83c98bc3d75c["prepareOutFolder()"]
  395c56cc_0c49_0b4c_347d_abe47b81589f -->|calls| 3f325b6b_14df_fa20_c5d7_83c98bc3d75c
  cb2d3951_4fcb_d824_359b_9f044d2f7e6c["writeResult()"]
  395c56cc_0c49_0b4c_347d_abe47b81589f -->|calls| cb2d3951_4fcb_d824_359b_9f044d2f7e6c
  style 395c56cc_0c49_0b4c_347d_abe47b81589f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/src/cli/commands/introspect.ts lines 181–305

export const introspectGel = async (
	casing: Casing,
	out: string,
	breakpoints: boolean,
	credentials: GelCredentials | undefined,
	tablesFilter: string[],
	schemasFilter: string[],
	prefix: Prefix,
	entities: Entities,
) => {
	const { prepareGelDB } = await import('../connections');
	const db = await prepareGelDB(credentials);

	const matchers = tablesFilter.map((it) => {
		return new Minimatch(it);
	});

	const filter = (tableName: string) => {
		if (matchers.length === 0) return true;

		let flags: boolean[] = [];

		for (let matcher of matchers) {
			if (matcher.negate) {
				if (!matcher.match(tableName)) {
					flags.push(false);
				}
			}

			if (matcher.match(tableName)) {
				flags.push(true);
			}
		}

		if (flags.length > 0) {
			return flags.every(Boolean);
		}
		return false;
	};

	const progress = new IntrospectProgress(true);

	const res = await renderWithTask(
		progress,
		fromGelDatabase(
			db,
			filter,
			schemasFilter,
			entities,
			(stage, count, status) => {
				progress.update(stage, count, status);
			},
		),
	);

	const schema = { id: originUUID, prevId: '', ...res } as GelSchema;
	const ts = gelSchemaToTypeScript(schema, casing);
	const relationsTs = relationsToTypeScript(schema, casing);
	const { internal, ...schemaWithoutInternals } = schema;

	const schemaFile = join(out, 'schema.ts');
	writeFileSync(schemaFile, ts.file);
	const relationsFile = join(out, 'relations.ts');
	writeFileSync(relationsFile, relationsTs.file);
	console.log();

	// const { snapshots, journal } = prepareOutFolder(out, 'gel');

	// if (snapshots.length === 0) {
	// 	const { sqlStatements, _meta } = await applyGelSnapshotsDiff(
	// 		squashGelScheme(dryGel),
	// 		squashGelScheme(schema),
	// 		schemasResolver,
	// 		enumsResolver,
	// 		sequencesResolver,
	// 		policyResolver,
	// 		indPolicyResolver,
	// 		roleResolver,
	// 		tablesResolver,
	// 		columnsResolver,
	// 		viewsResolver,

Domain

Subdomains

Frequently Asked Questions

What does introspectGel() do?
introspectGel() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/cli/commands/introspect.ts.
Where is introspectGel() defined?
introspectGel() is defined in drizzle-kit/src/cli/commands/introspect.ts at line 181.
What does introspectGel() call?
introspectGel() calls 4 function(s): prepareOutFolder, relationsToTypeScript, update, writeResult.

Analyze Your Own Codebase

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

Try Supermodel Free