Home / Class/ MyDurableObject Class — drizzle-orm Architecture

MyDurableObject Class — drizzle-orm Architecture

Architecture documentation for the MyDurableObject class in index.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  34f01008_7c45_3804_1fad_b8b59cd8a413["MyDurableObject"]
  6946043a_dab4_e149_5ebe_24dacb75bdf1["index.ts"]
  34f01008_7c45_3804_1fad_b8b59cd8a413 -->|defined in| 6946043a_dab4_e149_5ebe_24dacb75bdf1
  bdcd4dfb_1086_19bd_b371_655a2f18e326["constructor()"]
  34f01008_7c45_3804_1fad_b8b59cd8a413 -->|method| bdcd4dfb_1086_19bd_b371_655a2f18e326
  3d8eadef_04a9_b2ef_ce18_efa73bed54c9["migrate1()"]
  34f01008_7c45_3804_1fad_b8b59cd8a413 -->|method| 3d8eadef_04a9_b2ef_ce18_efa73bed54c9
  b19b108f_def7_3a32_99a3_c8be51ce2fbf["beforeEach()"]
  34f01008_7c45_3804_1fad_b8b59cd8a413 -->|method| b19b108f_def7_3a32_99a3_c8be51ce2fbf
  23ba490e_19fa_42f7_f901_dba9c9d61247["insertBigIntValues()"]
  34f01008_7c45_3804_1fad_b8b59cd8a413 -->|method| 23ba490e_19fa_42f7_f901_dba9c9d61247
  e97c5512_fedf_ab0a_d642_e6570966662e["selectAllFields()"]
  34f01008_7c45_3804_1fad_b8b59cd8a413 -->|method| e97c5512_fedf_ab0a_d642_e6570966662e
  b81e7633_189d_6225_944e_8ddb0bc58a48["selectPartial()"]
  34f01008_7c45_3804_1fad_b8b59cd8a413 -->|method| b81e7633_189d_6225_944e_8ddb0bc58a48
  563b1a2a_f3c0_e650_015d_9e35a5889dd1["selectSql()"]
  34f01008_7c45_3804_1fad_b8b59cd8a413 -->|method| 563b1a2a_f3c0_e650_015d_9e35a5889dd1
  8652c9d0_eddd_51cd_f52f_dda8f1e15ef9["selectTypedSql()"]
  34f01008_7c45_3804_1fad_b8b59cd8a413 -->|method| 8652c9d0_eddd_51cd_f52f_dda8f1e15ef9
  ad2fcaf6_d30c_e79b_4200_5876496e53d6["selectWithEmptyArrayInInArray()"]
  34f01008_7c45_3804_1fad_b8b59cd8a413 -->|method| ad2fcaf6_d30c_e79b_4200_5876496e53d6
  4507991e_6443_5a0c_e9b3_75f5efc65d32["selectWithEmptyArrayInNotInArray()"]
  34f01008_7c45_3804_1fad_b8b59cd8a413 -->|method| 4507991e_6443_5a0c_e9b3_75f5efc65d32
  3fb3cb2a_6cd1_2725_4f3d_9737f4168282["selectDistinct()"]
  34f01008_7c45_3804_1fad_b8b59cd8a413 -->|method| 3fb3cb2a_6cd1_2725_4f3d_9737f4168282
  9f2e2e3c_2306_6e83_715c_72cee06e8ada["returingSql()"]
  34f01008_7c45_3804_1fad_b8b59cd8a413 -->|method| 9f2e2e3c_2306_6e83_715c_72cee06e8ada
  3e673696_e95b_7cea_5616_d99b9a560101["$defaultFunction()"]
  34f01008_7c45_3804_1fad_b8b59cd8a413 -->|method| 3e673696_e95b_7cea_5616_d99b9a560101

Relationship Graph

Source Code

integration-tests/tests/sqlite/durable-objects/index.ts lines 194–3484

export class MyDurableObject extends DurableObject {
	storage: DurableObjectStorage;
	db: DrizzleSqliteDODatabase;
	constructor(ctx: DurableObjectState, env: Env) {
		super(ctx, env);
		this.storage = ctx.storage;
		this.db = drizzle(this.storage, { logger: false });
	}

	async migrate1(): Promise<void> {
		try {
			this.db.run(sql`drop table if exists another_users`);
			this.db.run(sql`drop table if exists users12`);
			this.db.run(sql`drop table if exists __drizzle_migrations`);

			migrate(this.db, migrations);

			this.db.insert(usersMigratorTable).values({ name: 'John', email: 'email' }).run();
			const result = this.db.select().from(usersMigratorTable).all();

			this.db.insert(anotherUsersMigratorTable).values({ name: 'John', email: 'email' }).run();
			const result2 = this.db.select().from(anotherUsersMigratorTable).all();

			expect(result).deep.equal([{ id: 1, name: 'John', email: 'email' }]);
			expect(result2).deep.equal([{ id: 1, name: 'John', email: 'email' }]);

			this.db.run(sql`drop table another_users`);
			this.db.run(sql`drop table users12`);
			this.db.run(sql`drop table __drizzle_migrations`);
		} catch {
			throw new Error('migrate1 has broken');
		}
	}

	async beforeEach(): Promise<void> {
		this.db.run(sql`drop table if exists ${usersTable}`);
		this.db.run(sql`drop table if exists ${users2Table}`);
		this.db.run(sql`drop table if exists ${citiesTable}`);
		this.db.run(sql`drop table if exists ${coursesTable}`);
		this.db.run(sql`drop table if exists ${courseCategoriesTable}`);
		this.db.run(sql`drop table if exists ${orders}`);
		this.db.run(sql`drop table if exists ${bigIntExample}`);
		this.db.run(sql`drop table if exists ${pkExampleTable}`);
		this.db.run(sql`drop table if exists user_notifications_insert_into`);
		this.db.run(sql`drop table if exists users_insert_into`);
		this.db.run(sql`drop table if exists notifications_insert_into`);

		this.db.run(sql`
			create table ${usersTable} (
				id integer primary key,
				name text not null,
				verified integer not null default 0,
				json blob,
				created_at integer not null default (strftime('%s', 'now'))
			)
		`);

		this.db.run(sql`
			create table ${citiesTable} (
				id integer primary key,
				name text not null
			)
		`);
		this.db.run(sql`
			create table ${courseCategoriesTable} (
				id integer primary key,
				name text not null
			)
		`);

		this.db.run(sql`
			create table ${users2Table} (
				id integer primary key,
				name text not null,
				city_id integer references ${citiesTable}(${sql.identifier(citiesTable.id.name)})
			)
		`);
		this.db.run(sql`
			create table ${coursesTable} (
				id integer primary key,
				name text not null,

Domain

Frequently Asked Questions

What is the MyDurableObject class?
MyDurableObject is a class in the drizzle-orm codebase, defined in integration-tests/tests/sqlite/durable-objects/index.ts.
Where is MyDurableObject defined?
MyDurableObject is defined in integration-tests/tests/sqlite/durable-objects/index.ts at line 194.

Analyze Your Own Codebase

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

Try Supermodel Free