Select

select Method Documentation

The select method specifies the columns to retrieve from a data source. It supports selecting single columns, multiple columns, and dynamically generated columns.

Note:

After finishing building your query attach .build() to generate it.


Method Signature

select(columns: keyof T | (keyof T)[]): this;

Parameters

  • columns:
    • A single column name as a string
    • An array of column names.

Returns

The current instance, allowing method chaining.


Examples

1. Single Column Selection

query.select("name");

2. Multiple Columns Selection (Array)

query.select(["name", "email", "age"]);

3. Dynamic Columns (Type-Safe)

const columns: (keyof User)[] = ["id", "email"];
query.select(columns);

Select Cases Table

FormatExampleUse Case
Single Columnquery.select("name")Retrieve one column
Multiple Columnsquery.select(["name", "email"])Retrieve multiple columns
Dynamic Columns Arrayquery.select(columns)Type-safe dynamic selection