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

prepareRoles() — drizzle-orm Function Reference

Architecture documentation for the prepareRoles() function in gelSerializer.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  8283674e_ae81_08ec_a8a3_dfb34d1ada33["prepareRoles()"]
  33990744_4141_72e3_2ae9_3c695bf71d75["gelSerializer.ts"]
  8283674e_ae81_08ec_a8a3_dfb34d1ada33 -->|defined in| 33990744_4141_72e3_2ae9_3c695bf71d75
  style 8283674e_ae81_08ec_a8a3_dfb34d1ada33 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/src/serializer/gelSerializer.ts lines 912–952

function prepareRoles(entities?: {
	roles: boolean | {
		provider?: string | undefined;
		include?: string[] | undefined;
		exclude?: string[] | undefined;
	};
}) {
	let useRoles: boolean = false;
	const includeRoles: string[] = [];
	const excludeRoles: string[] = [];

	if (entities && entities.roles) {
		if (typeof entities.roles === 'object') {
			if (entities.roles.provider) {
				if (entities.roles.provider === 'supabase') {
					excludeRoles.push(...[
						'anon',
						'authenticator',
						'authenticated',
						'service_role',
						'supabase_auth_admin',
						'supabase_storage_admin',
						'dashboard_user',
						'supabase_admin',
					]);
				} else if (entities.roles.provider === 'neon') {
					excludeRoles.push(...['authenticated', 'anonymous']);
				}
			}
			if (entities.roles.include) {
				includeRoles.push(...entities.roles.include);
			}
			if (entities.roles.exclude) {
				excludeRoles.push(...entities.roles.exclude);
			}
		} else {
			useRoles = entities.roles;
		}
	}
	return { useRoles, includeRoles, excludeRoles };
}

Domain

Subdomains

Frequently Asked Questions

What does prepareRoles() do?
prepareRoles() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/serializer/gelSerializer.ts.
Where is prepareRoles() defined?
prepareRoles() is defined in drizzle-kit/src/serializer/gelSerializer.ts at line 912.

Analyze Your Own Codebase

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

Try Supermodel Free