Home / Class/ ServerSimulator Class — drizzle-orm Architecture

ServerSimulator Class — drizzle-orm Architecture

Architecture documentation for the ServerSimulator class in sqlite-proxy.test.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  a479bb61_1b30_0722_aeaf_83aee1a094b3["ServerSimulator"]
  96b7f482_cbb7_44ab_3fc0_369276a1c78c["sqlite-proxy.test.ts"]
  a479bb61_1b30_0722_aeaf_83aee1a094b3 -->|defined in| 96b7f482_cbb7_44ab_3fc0_369276a1c78c
  ee17177b_ef3e_975b_0178_d66f6b787fad["constructor()"]
  a479bb61_1b30_0722_aeaf_83aee1a094b3 -->|method| ee17177b_ef3e_975b_0178_d66f6b787fad
  6aa860df_11ec_11d0_293b_7606da100a1d["query()"]
  a479bb61_1b30_0722_aeaf_83aee1a094b3 -->|method| 6aa860df_11ec_11d0_293b_7606da100a1d
  2225754a_cf90_fb3c_a8a2_5034c066d3fd["migrations()"]
  a479bb61_1b30_0722_aeaf_83aee1a094b3 -->|method| 2225754a_cf90_fb3c_a8a2_5034c066d3fd

Relationship Graph

Source Code

integration-tests/tests/sqlite/sqlite-proxy.test.ts lines 12–55

class ServerSimulator {
	constructor(private db: BetterSqlite3.Database) {}

	async query(sql: string, params: any[], method: string) {
		if (method === 'run') {
			try {
				const result = this.db.prepare(sql).run(params);
				return { data: result as any };
			} catch (e: any) {
				return { error: e.message };
			}
		} else if (method === 'all' || method === 'values') {
			try {
				const rows = this.db.prepare(sql).raw().all(params);
				return { data: rows };
			} catch (e: any) {
				return { error: e.message };
			}
		} else if (method === 'get') {
			try {
				const row = this.db.prepare(sql).raw().get(params);
				return { data: row };
			} catch (e: any) {
				return { error: e.message };
			}
		} else {
			return { error: 'Unknown method value' };
		}
	}

	migrations(queries: string[]) {
		this.db.exec('BEGIN');
		try {
			for (const query of queries) {
				this.db.exec(query);
			}
			this.db.exec('COMMIT');
		} catch {
			this.db.exec('ROLLBACK');
		}

		return {};
	}
}

Domain

Frequently Asked Questions

What is the ServerSimulator class?
ServerSimulator is a class in the drizzle-orm codebase, defined in integration-tests/tests/sqlite/sqlite-proxy.test.ts.
Where is ServerSimulator defined?
ServerSimulator is defined in integration-tests/tests/sqlite/sqlite-proxy.test.ts at line 12.

Analyze Your Own Codebase

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

Try Supermodel Free