json.ts — drizzle-orm Source File
Architecture documentation for json.ts, a typescript file in the drizzle-orm codebase. 6 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 9cf33382_6a25_c3a9_0185_da2af17a8484["json.ts"] f4f42b4c_8610_03dd_fe01_232098668127["common.ts"] 9cf33382_6a25_c3a9_0185_da2af17a8484 --> f4f42b4c_8610_03dd_fe01_232098668127 099d7c6d_2fc4_7b20_40e3_1b8af4138fe6["PgColumn"] 9cf33382_6a25_c3a9_0185_da2af17a8484 --> 099d7c6d_2fc4_7b20_40e3_1b8af4138fe6 2dc784c6_95e9_4e28_ec81_7caf4acbd426["column-builder.ts"] 9cf33382_6a25_c3a9_0185_da2af17a8484 --> 2dc784c6_95e9_4e28_ec81_7caf4acbd426 05f0a280_d0c9_693a_a4bf_83cc671012d2["column.ts"] 9cf33382_6a25_c3a9_0185_da2af17a8484 --> 05f0a280_d0c9_693a_a4bf_83cc671012d2 27705a9d_afe9_57dd_8c97_e52d8a67d426["entity.ts"] 9cf33382_6a25_c3a9_0185_da2af17a8484 --> 27705a9d_afe9_57dd_8c97_e52d8a67d426 17418917_ff81_c4e5_90f4_f37d557e5d51["table.ts"] 9cf33382_6a25_c3a9_0185_da2af17a8484 --> 17418917_ff81_c4e5_90f4_f37d557e5d51 b38cf654_48d6_41dc_6c0f_203697984d98["all.ts"] b38cf654_48d6_41dc_6c0f_203697984d98 --> 9cf33382_6a25_c3a9_0185_da2af17a8484 style 9cf33382_6a25_c3a9_0185_da2af17a8484 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';
import type { ColumnBaseConfig } from '~/column.ts';
import { entityKind } from '~/entity.ts';
import type { AnyPgTable } from '~/pg-core/table.ts';
import { PgColumn, PgColumnBuilder } from './common.ts';
export type PgJsonBuilderInitial<TName extends string> = PgJsonBuilder<{
name: TName;
dataType: 'json';
columnType: 'PgJson';
data: unknown;
driverParam: unknown;
enumValues: undefined;
}>;
export class PgJsonBuilder<T extends ColumnBuilderBaseConfig<'json', 'PgJson'>> extends PgColumnBuilder<
T
> {
static override readonly [entityKind]: string = 'PgJsonBuilder';
constructor(name: T['name']) {
super(name, 'json', 'PgJson');
}
/** @internal */
override build<TTableName extends string>(
table: AnyPgTable<{ name: TTableName }>,
): PgJson<MakeColumnConfig<T, TTableName>> {
return new PgJson<MakeColumnConfig<T, TTableName>>(table, this.config as ColumnBuilderRuntimeConfig<any, any>);
}
}
export class PgJson<T extends ColumnBaseConfig<'json', 'PgJson'>> extends PgColumn<T> {
static override readonly [entityKind]: string = 'PgJson';
constructor(table: AnyPgTable<{ name: T['tableName'] }>, config: PgJsonBuilder<T>['config']) {
super(table, config);
}
getSQLType(): string {
return 'json';
}
override mapToDriverValue(value: T['data']): string {
return JSON.stringify(value);
}
override mapFromDriverValue(value: T['data'] | string): T['data'] {
if (typeof value === 'string') {
try {
return JSON.parse(value);
} catch {
return value as T['data'];
}
}
return value;
}
}
export function json(): PgJsonBuilderInitial<''>;
export function json<TName extends string>(name: TName): PgJsonBuilderInitial<TName>;
export function json(name?: string) {
return new PgJsonBuilder(name ?? '');
}
Domain
Subdomains
Functions
Classes
Types
Imported By
Source
Frequently Asked Questions
What does json.ts do?
json.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 json.ts?
json.ts defines 1 function(s): json.
What does json.ts depend on?
json.ts imports 6 module(s): PgColumn, column-builder.ts, column.ts, common.ts, entity.ts, table.ts.
What files import json.ts?
json.ts is imported by 1 file(s): all.ts.
Where is json.ts in the architecture?
json.ts is located at drizzle-orm/src/pg-core/columns/json.ts (domain: DrizzleORM, subdomain: DatabaseDrivers, directory: drizzle-orm/src/pg-core/columns).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free