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

blob.ts — drizzle-orm Source File

Architecture documentation for blob.ts, a typescript file in the drizzle-orm codebase. 7 imports, 1 dependents.

File typescript DrizzleORM SQLDialects 7 imports 1 dependents 1 functions 6 classes

Entity Profile

Dependency Diagram

graph LR
  5c8a5ab6_4356_4d2f_782b_4e0b3b38b801["blob.ts"]
  a4c1e5cb_a206_4786_985b_0e0a35ddd536["common.ts"]
  5c8a5ab6_4356_4d2f_782b_4e0b3b38b801 --> a4c1e5cb_a206_4786_985b_0e0a35ddd536
  f78ef1e1_d140_1e8a_3de5_d93a866c939f["SQLiteColumn"]
  5c8a5ab6_4356_4d2f_782b_4e0b3b38b801 --> f78ef1e1_d140_1e8a_3de5_d93a866c939f
  2dc784c6_95e9_4e28_ec81_7caf4acbd426["column-builder.ts"]
  5c8a5ab6_4356_4d2f_782b_4e0b3b38b801 --> 2dc784c6_95e9_4e28_ec81_7caf4acbd426
  05f0a280_d0c9_693a_a4bf_83cc671012d2["column.ts"]
  5c8a5ab6_4356_4d2f_782b_4e0b3b38b801 --> 05f0a280_d0c9_693a_a4bf_83cc671012d2
  27705a9d_afe9_57dd_8c97_e52d8a67d426["entity.ts"]
  5c8a5ab6_4356_4d2f_782b_4e0b3b38b801 --> 27705a9d_afe9_57dd_8c97_e52d8a67d426
  227c0a5e_dd35_a654_1766_5a30cb1b922f["table.ts"]
  5c8a5ab6_4356_4d2f_782b_4e0b3b38b801 --> 227c0a5e_dd35_a654_1766_5a30cb1b922f
  ecce3253_1e75_a87f_27b3_ca87e81a3024["utils.ts"]
  5c8a5ab6_4356_4d2f_782b_4e0b3b38b801 --> ecce3253_1e75_a87f_27b3_ca87e81a3024
  0bca2cbd_0e97_da69_ba34_0de360b77802["all.ts"]
  0bca2cbd_0e97_da69_ba34_0de360b77802 --> 5c8a5ab6_4356_4d2f_782b_4e0b3b38b801
  style 5c8a5ab6_4356_4d2f_782b_4e0b3b38b801 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 { AnySQLiteTable } from '~/sqlite-core/table.ts';
import { type Equal, getColumnNameAndConfig, textDecoder } from '~/utils.ts';
import { SQLiteColumn, SQLiteColumnBuilder } from './common.ts';

type BlobMode = 'buffer' | 'json' | 'bigint';

export type SQLiteBigIntBuilderInitial<TName extends string> = SQLiteBigIntBuilder<{
	name: TName;
	dataType: 'bigint';
	columnType: 'SQLiteBigInt';
	data: bigint;
	driverParam: Buffer;
	enumValues: undefined;
}>;

export class SQLiteBigIntBuilder<T extends ColumnBuilderBaseConfig<'bigint', 'SQLiteBigInt'>>
	extends SQLiteColumnBuilder<T>
{
	static override readonly [entityKind]: string = 'SQLiteBigIntBuilder';

	constructor(name: T['name']) {
		super(name, 'bigint', 'SQLiteBigInt');
	}

	/** @internal */
	override build<TTableName extends string>(
		table: AnySQLiteTable<{ name: TTableName }>,
	): SQLiteBigInt<MakeColumnConfig<T, TTableName>> {
		return new SQLiteBigInt<MakeColumnConfig<T, TTableName>>(table, this.config as ColumnBuilderRuntimeConfig<any>);
	}
}

export class SQLiteBigInt<T extends ColumnBaseConfig<'bigint', 'SQLiteBigInt'>> extends SQLiteColumn<T> {
	static override readonly [entityKind]: string = 'SQLiteBigInt';

	getSQLType(): string {
		return 'blob';
	}

	override mapFromDriverValue(value: Buffer | Uint8Array | ArrayBuffer): bigint {
		if (typeof Buffer !== 'undefined' && Buffer.from) {
			const buf = Buffer.isBuffer(value)
				? value
				// eslint-disable-next-line no-instanceof/no-instanceof
				: value instanceof ArrayBuffer
				? Buffer.from(value)
				: value.buffer
				? Buffer.from(value.buffer, value.byteOffset, value.byteLength)
				: Buffer.from(value);
			return BigInt(buf.toString('utf8'));
		}

		return BigInt(textDecoder!.decode(value));
	}

	override mapToDriverValue(value: bigint): Buffer {
		return Buffer.from(value.toString());
// ... (135 more lines)

Domain

Subdomains

Functions

Dependencies

Frequently Asked Questions

What does blob.ts do?
blob.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain, SQLDialects subdomain.
What functions are defined in blob.ts?
blob.ts defines 1 function(s): blob.
What does blob.ts depend on?
blob.ts imports 7 module(s): SQLiteColumn, column-builder.ts, column.ts, common.ts, entity.ts, table.ts, utils.ts.
What files import blob.ts?
blob.ts is imported by 1 file(s): all.ts.
Where is blob.ts in the architecture?
blob.ts is located at drizzle-orm/src/sqlite-core/columns/blob.ts (domain: DrizzleORM, subdomain: SQLDialects, directory: drizzle-orm/src/sqlite-core/columns).

Analyze Your Own Codebase

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

Try Supermodel Free