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

createTablePolicies() — drizzle-orm Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  fa9ff7be_dc3f_2f25_835c_09506519ceba["createTablePolicies()"]
  ac795a29_c480_454a_c930_ea8898cad46c["introspect-gel.ts"]
  fa9ff7be_dc3f_2f25_835c_09506519ceba -->|defined in| ac795a29_c480_454a_c930_ea8898cad46c
  d6ed66aa_aafe_f478_835c_7c02934633eb["schemaToTypeScript()"]
  d6ed66aa_aafe_f478_835c_7c02934633eb -->|calls| fa9ff7be_dc3f_2f25_835c_09506519ceba
  13b884c4_04ee_3a07_de49_bfbf8819424d["withCasing()"]
  fa9ff7be_dc3f_2f25_835c_09506519ceba -->|calls| 13b884c4_04ee_3a07_de49_bfbf8819424d
  style fa9ff7be_dc3f_2f25_835c_09506519ceba fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/src/introspect-gel.ts lines 1004–1028

const createTablePolicies = (
	policies: Policy[],
	casing: Casing,
	rolesNameToTsKey: Record<string, string> = {},
): string => {
	let statement = '';

	policies.forEach((it) => {
		const idxKey = withCasing(it.name, casing);

		const mappedItTo = it.to?.map((v) => {
			return rolesNameToTsKey[v] ? withCasing(rolesNameToTsKey[v], casing) : `"${v}"`;
		});

		statement += `\n\t`;
		statement += 'gelPolicy(';
		statement += `"${it.name}", { `;
		statement += `as: "${it.as?.toLowerCase()}", for: "${it.for?.toLowerCase()}", to: [${mappedItTo?.join(', ')}]${
			it.using ? `, using: sql\`${it.using}\`` : ''
		}${it.withCheck ? `, withCheck: sql\`${it.withCheck}\` ` : ''}`;
		statement += ` }),`;
	});

	return statement;
};

Domain

Subdomains

Calls

Frequently Asked Questions

What does createTablePolicies() do?
createTablePolicies() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/introspect-gel.ts.
Where is createTablePolicies() defined?
createTablePolicies() is defined in drizzle-kit/src/introspect-gel.ts at line 1004.
What does createTablePolicies() call?
createTablePolicies() calls 1 function(s): withCasing.
What calls createTablePolicies()?
createTablePolicies() is called by 1 function(s): schemaToTypeScript.

Analyze Your Own Codebase

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

Try Supermodel Free