Home / File/ policies.ts — drizzle-orm Source File

policies.ts — drizzle-orm Source File

Architecture documentation for policies.ts, a typescript file in the drizzle-orm codebase. 4 imports, 2 dependents.

File typescript DrizzleORM DatabaseDrivers 4 imports 2 dependents 1 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  85575027_808b_f07e_b2a8_8d47e8b3189b["policies.ts"]
  ec737a7b_d290_c457_5fa4_eec6d91d420e["roles.ts"]
  85575027_808b_f07e_b2a8_8d47e8b3189b --> ec737a7b_d290_c457_5fa4_eec6d91d420e
  2d5c8884_973c_561c_def6_5e394ea36d1a["table.ts"]
  85575027_808b_f07e_b2a8_8d47e8b3189b --> 2d5c8884_973c_561c_def6_5e394ea36d1a
  27705a9d_afe9_57dd_8c97_e52d8a67d426["entity.ts"]
  85575027_808b_f07e_b2a8_8d47e8b3189b --> 27705a9d_afe9_57dd_8c97_e52d8a67d426
  be483a7f_d5d7_7a9b_9a13_44a4a6aafbbd["sql.ts"]
  85575027_808b_f07e_b2a8_8d47e8b3189b --> be483a7f_d5d7_7a9b_9a13_44a4a6aafbbd
  2d5c8884_973c_561c_def6_5e394ea36d1a["table.ts"]
  2d5c8884_973c_561c_def6_5e394ea36d1a --> 85575027_808b_f07e_b2a8_8d47e8b3189b
  ce49a5a3_688d_ddce_fd32_28428e51cae2["utils.ts"]
  ce49a5a3_688d_ddce_fd32_28428e51cae2 --> 85575027_808b_f07e_b2a8_8d47e8b3189b
  style 85575027_808b_f07e_b2a8_8d47e8b3189b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { entityKind } from '~/entity.ts';
import type { SQL } from '~/sql/sql.ts';
import type { PgRole } from './roles.ts';
import type { PgTable } from './table.ts';

export type PgPolicyToOption =
	| 'public'
	| 'current_role'
	| 'current_user'
	| 'session_user'
	| (string & {})
	| PgPolicyToOption[]
	| PgRole;

export interface PgPolicyConfig {
	as?: 'permissive' | 'restrictive';
	for?: 'all' | 'select' | 'insert' | 'update' | 'delete';
	to?: PgPolicyToOption;
	using?: SQL;
	withCheck?: SQL;
}

export class PgPolicy implements PgPolicyConfig {
	static readonly [entityKind]: string = 'PgPolicy';

	readonly as: PgPolicyConfig['as'];
	readonly for: PgPolicyConfig['for'];
	readonly to: PgPolicyConfig['to'];
	readonly using: PgPolicyConfig['using'];
	readonly withCheck: PgPolicyConfig['withCheck'];

	/** @internal */
	_linkedTable?: PgTable;

	constructor(
		readonly name: string,
		config?: PgPolicyConfig,
	) {
		if (config) {
			this.as = config.as;
			this.for = config.for;
			this.to = config.to;
			this.using = config.using;
			this.withCheck = config.withCheck;
		}
	}

	link(table: PgTable): this {
		this._linkedTable = table;
		return this;
	}
}

export function pgPolicy(name: string, config?: PgPolicyConfig) {
	return new PgPolicy(name, config);
}

Domain

Subdomains

Functions

Classes

Dependencies

Frequently Asked Questions

What does policies.ts do?
policies.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain, DatabaseDrivers subdomain.
What functions are defined in policies.ts?
policies.ts defines 1 function(s): pgPolicy.
What does policies.ts depend on?
policies.ts imports 4 module(s): entity.ts, roles.ts, sql.ts, table.ts.
What files import policies.ts?
policies.ts is imported by 2 file(s): table.ts, utils.ts.
Where is policies.ts in the architecture?
policies.ts is located at drizzle-orm/src/pg-core/policies.ts (domain: DrizzleORM, subdomain: DatabaseDrivers, directory: drizzle-orm/src/pg-core).

Analyze Your Own Codebase

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

Try Supermodel Free