Home / Function/ selectDistinct() — drizzle-orm Function Reference

selectDistinct() — drizzle-orm Function Reference

Architecture documentation for the selectDistinct() function in index.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  3fb3cb2a_6cd1_2725_4f3d_9737f4168282["selectDistinct()"]
  34f01008_7c45_3804_1fad_b8b59cd8a413["MyDurableObject"]
  3fb3cb2a_6cd1_2725_4f3d_9737f4168282 -->|defined in| 34f01008_7c45_3804_1fad_b8b59cd8a413
  7c7acbfe_6328_c8df_feba_552ee62a84d9["default.fetch()"]
  7c7acbfe_6328_c8df_feba_552ee62a84d9 -->|calls| 3fb3cb2a_6cd1_2725_4f3d_9737f4168282
  b19b108f_def7_3a32_99a3_c8be51ce2fbf["beforeEach()"]
  3fb3cb2a_6cd1_2725_4f3d_9737f4168282 -->|calls| b19b108f_def7_3a32_99a3_c8be51ce2fbf
  style 3fb3cb2a_6cd1_2725_4f3d_9737f4168282 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

integration-tests/tests/sqlite/durable-objects/index.ts lines 451–488

	async selectDistinct(): Promise<void> {
		try {
			await this.beforeEach();

			const usersDistinctTable = sqliteTable('users_distinct', {
				id: integer('id').notNull(),
				name: text('name').notNull(),
			});

			this.db.run(sql`drop table if exists ${usersDistinctTable}`);
			this.db.run(sql`create table ${usersDistinctTable} (id integer, name text)`);

			this.db
				.insert(usersDistinctTable)
				.values([
					{ id: 1, name: 'John' },
					{ id: 1, name: 'John' },
					{ id: 2, name: 'John' },
					{ id: 1, name: 'Jane' },
				])
				.run();
			const users = this.db.selectDistinct().from(usersDistinctTable).orderBy(
				usersDistinctTable.id,
				usersDistinctTable.name,
			).all();

			this.db.run(sql`drop table ${usersDistinctTable}`);

			expect(users).deep.equal([
				{ id: 1, name: 'Jane' },
				{ id: 1, name: 'John' },
				{ id: 2, name: 'John' },
			]);
		} catch (error: any) {
			console.error(error);
			throw new Error('selectDistinct has broken');
		}
	}

Domain

Subdomains

Calls

Called By

Frequently Asked Questions

What does selectDistinct() do?
selectDistinct() is a function in the drizzle-orm codebase, defined in integration-tests/tests/sqlite/durable-objects/index.ts.
Where is selectDistinct() defined?
selectDistinct() is defined in integration-tests/tests/sqlite/durable-objects/index.ts at line 451.
What does selectDistinct() call?
selectDistinct() calls 1 function(s): beforeEach.
What calls selectDistinct()?
selectDistinct() is called by 1 function(s): default.fetch.

Analyze Your Own Codebase

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

Try Supermodel Free