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

prepareSingleStoreSchema() — drizzle-orm Function Reference

Architecture documentation for the prepareSingleStoreSchema() function in studio.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  57be83db_8cac_c634_0fc7_fef23aff8214["prepareSingleStoreSchema()"]
  82de12f8_a8ca_9d38_8da8_9ac945d81e01["studio.ts"]
  57be83db_8cac_c634_0fc7_fef23aff8214 -->|defined in| 82de12f8_a8ca_9d38_8da8_9ac945d81e01
  72630e5c_93c3_75d3_29f3_af0928ebe15c["studio.handler()"]
  72630e5c_93c3_75d3_29f3_af0928ebe15c -->|calls| 57be83db_8cac_c634_0fc7_fef23aff8214
  54221957_c725_0bfe_4345_4f3837d39296["safeRegister()"]
  57be83db_8cac_c634_0fc7_fef23aff8214 -->|calls| 54221957_c725_0bfe_4345_4f3837d39296
  style 57be83db_8cac_c634_0fc7_fef23aff8214 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/src/serializer/studio.ts lines 200–238

export const prepareSingleStoreSchema = async (path: string | string[]) => {
	const imports = prepareFilenames(path);
	const singlestoreSchema: Record<
		string,
		Record<string, AnySingleStoreTable>
	> = {
		public: {},
	};
	const relations: Record<string, Relations> = {};

	// files content as string
	const files = imports.map((it, index) => ({
		// get the file name from the path
		name: it.split('/').pop() || `schema${index}.ts`,
		content: fs.readFileSync(it, 'utf-8'),
	}));

	const { unregister } = await safeRegister();
	for (let i = 0; i < imports.length; i++) {
		const it = imports[i];

		const i0: Record<string, unknown> = require(`${it}`);
		const i0values = Object.entries(i0);

		i0values.forEach(([k, t]) => {
			if (is(t, SingleStoreTable)) {
				const schema = singlestoreTableConfig(t).schema || 'public';
				singlestoreSchema[schema][k] = t;
			}

			if (is(t, Relations)) {
				relations[k] = t;
			}
		});
	}
	unregister();

	return { schema: singlestoreSchema, relations, files };
};

Domain

Subdomains

Called By

Frequently Asked Questions

What does prepareSingleStoreSchema() do?
prepareSingleStoreSchema() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/serializer/studio.ts.
Where is prepareSingleStoreSchema() defined?
prepareSingleStoreSchema() is defined in drizzle-kit/src/serializer/studio.ts at line 200.
What does prepareSingleStoreSchema() call?
prepareSingleStoreSchema() calls 1 function(s): safeRegister.
What calls prepareSingleStoreSchema()?
prepareSingleStoreSchema() is called by 1 function(s): studio.handler.

Analyze Your Own Codebase

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

Try Supermodel Free