createTablePolicies() — drizzle-orm Function Reference
Architecture documentation for the createTablePolicies() function in introspect-pg.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD cdb1f2e5_6be0_6765_9367_ec66357c1205["createTablePolicies()"] 71516551_23e3_bf30_27c9_000fb046ef71["introspect-pg.ts"] cdb1f2e5_6be0_6765_9367_ec66357c1205 -->|defined in| 71516551_23e3_bf30_27c9_000fb046ef71 ae4bc88a_1e24_ce7b_ea80_728e39b829ef["schemaToTypeScript()"] ae4bc88a_1e24_ce7b_ea80_728e39b829ef -->|calls| cdb1f2e5_6be0_6765_9367_ec66357c1205 968467a1_c4a6_11cb_5fbc_8854071f9af4["withCasing()"] cdb1f2e5_6be0_6765_9367_ec66357c1205 -->|calls| 968467a1_c4a6_11cb_5fbc_8854071f9af4 style cdb1f2e5_6be0_6765_9367_ec66357c1205 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-kit/src/introspect-pg.ts lines 1282–1306
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 += 'pgPolicy(';
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
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does createTablePolicies() do?
createTablePolicies() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/introspect-pg.ts.
Where is createTablePolicies() defined?
createTablePolicies() is defined in drizzle-kit/src/introspect-pg.ts at line 1282.
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