Home / Class/ Select Class — drizzle-orm Architecture

Select Class — drizzle-orm Architecture

Architecture documentation for the Select class in selector-ui.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  9934e2c6_9f05_2845_f34b_12d10c0c69f6["Select"]
  78dc1315_e71e_ad0d_dd8e_8ff968c12ee5["selector-ui.ts"]
  9934e2c6_9f05_2845_f34b_12d10c0c69f6 -->|defined in| 78dc1315_e71e_ad0d_dd8e_8ff968c12ee5
  9a17900f_37e8_b5de_5d4f_fef9e758226a["constructor()"]
  9934e2c6_9f05_2845_f34b_12d10c0c69f6 -->|method| 9a17900f_37e8_b5de_5d4f_fef9e758226a
  a6191ddf_c119_718d_8adb_1cf1f8e385b3["render()"]
  9934e2c6_9f05_2845_f34b_12d10c0c69f6 -->|method| a6191ddf_c119_718d_8adb_1cf1f8e385b3
  40f4b781_752a_c61d_30d7_98733975fdcd["result()"]
  9934e2c6_9f05_2845_f34b_12d10c0c69f6 -->|method| 40f4b781_752a_c61d_30d7_98733975fdcd

Relationship Graph

Source Code

drizzle-kit/src/cli/selector-ui.ts lines 4–38

export class Select extends Prompt<{ index: number; value: string }> {
	private readonly data: SelectState<{ label: string; value: string }>;

	constructor(items: string[]) {
		super();
		this.on('attach', (terminal) => terminal.toggleCursor('hide'));
		this.on('detach', (terminal) => terminal.toggleCursor('show'));

		this.data = new SelectState(
			items.map((it) => ({ label: it, value: `${it}-value` })),
		);
		this.data.bind(this);
	}

	render(status: 'idle' | 'submitted' | 'aborted'): string {
		if (status === 'submitted' || status === 'aborted') return '';

		let text = ``;
		this.data.items.forEach((it, idx) => {
			text += idx === this.data.selectedIdx
				? `${chalk.green('❯ ' + it.label)}`
				: `  ${it.label}`;
			text += idx != this.data.items.length - 1 ? '\n' : '';
		});

		return text;
	}

	result() {
		return {
			index: this.data.selectedIdx,
			value: this.data.items[this.data.selectedIdx]!.value!,
		};
	}
}

Domain

Frequently Asked Questions

What is the Select class?
Select is a class in the drizzle-orm codebase, defined in drizzle-kit/src/cli/selector-ui.ts.
Where is Select defined?
Select is defined in drizzle-kit/src/cli/selector-ui.ts at line 4.

Analyze Your Own Codebase

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

Try Supermodel Free