Home / File/ sqlite.test.ts — drizzle-orm Source File

sqlite.test.ts — drizzle-orm Source File

Architecture documentation for sqlite.test.ts, a typescript file in the drizzle-orm codebase. 5 imports, 0 dependents.

File typescript 5 imports

Entity Profile

Dependency Diagram

graph LR
  cf28f710_8b8d_a0cd_86ac_ccc04b1767ae["sqlite.test.ts"]
  8925695b_3773_48b7_06d1_2b60c9ed1057["bun:sqlite"]
  cf28f710_8b8d_a0cd_86ac_ccc04b1767ae --> 8925695b_3773_48b7_06d1_2b60c9ed1057
  37d03d06_666b_5949_8cbd_2874e6db22dc["bun:test"]
  cf28f710_8b8d_a0cd_86ac_ccc04b1767ae --> 37d03d06_666b_5949_8cbd_2874e6db22dc
  690f7dfc_0aea_9ee8_d6e7_26bbb3689031["drizzle-orm"]
  cf28f710_8b8d_a0cd_86ac_ccc04b1767ae --> 690f7dfc_0aea_9ee8_d6e7_26bbb3689031
  0f536c46_cb7e_9bc4_fdab_a06ec204d431["bun-sqlite"]
  cf28f710_8b8d_a0cd_86ac_ccc04b1767ae --> 0f536c46_cb7e_9bc4_fdab_a06ec204d431
  25248a9d_ba06_2b33_4421_8575da2f9c34["sqlite-core"]
  cf28f710_8b8d_a0cd_86ac_ccc04b1767ae --> 25248a9d_ba06_2b33_4421_8575da2f9c34
  style cf28f710_8b8d_a0cd_86ac_ccc04b1767ae fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { Database } from 'bun:sqlite';
import { beforeAll, beforeEach, expect, test } from 'bun:test';
import { sql } from 'drizzle-orm';
import type { BunSQLiteDatabase } from 'drizzle-orm/bun-sqlite';
import { drizzle } from 'drizzle-orm/bun-sqlite';
import { blob, integer, sqliteTable, text } from 'drizzle-orm/sqlite-core';

const usersTable = sqliteTable('users', {
	id: integer('id').primaryKey(),
	name: text('name').notNull(),
	verified: integer('verified').notNull().default(0),
	json: blob('json', { mode: 'json' }).$type<string[]>(),
	bigInt: blob('big_int', { mode: 'bigint' }),
	createdAt: integer('created_at', { mode: 'timestamp_ms' }).notNull().default(sql`strftime('%s', 'now')`),
});

let db: BunSQLiteDatabase;

beforeAll(async () => {
	try {
		const dbPath = process.env['SQLITE_DB_PATH'] ?? ':memory:';

		const client = new Database(dbPath);
		db = drizzle(client);
	} catch (e) {
		console.error(e);
	}
});

beforeEach(async () => {
	try {
		db.run(sql`drop table if exists ${usersTable}`);
		db.run(sql`
			create table ${usersTable} (
				id integer primary key,
				name text not null,
				verified integer not null default 0,
				json blob,
				big_int blob,
				created_at integer not null default (strftime('%s', 'now'))
			)
		`);
	} catch (e) {
		console.error(e);
	}
});

test.skip('select large integer', () => {
	const a = 1667476703000;
	const res = db.all<{ a: number }>(sql`select ${sql.raw(String(a))} as a`);
	const result = res[0]!;
	expect(result.a).toEqual(a);
});

test('select all fields', () => {
	const now = Date.now();

	db.insert(usersTable).values({ name: 'John' }).run();
	const result = db.select().from(usersTable).all()[0]!;

// ... (224 more lines)

Dependencies

  • bun-sqlite
  • bun:sqlite
  • bun:test
  • drizzle-orm
  • sqlite-core

Frequently Asked Questions

What does sqlite.test.ts do?
sqlite.test.ts is a source file in the drizzle-orm codebase, written in typescript.
What does sqlite.test.ts depend on?
sqlite.test.ts imports 5 module(s): bun-sqlite, bun:sqlite, bun:test, drizzle-orm, sqlite-core.
Where is sqlite.test.ts in the architecture?
sqlite.test.ts is located at integration-tests/tests/bun/sqlite.test.ts (directory: integration-tests/tests/bun).

Analyze Your Own Codebase

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

Try Supermodel Free