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
Format | Example | Use Case |
---|---|---|
Single Column | query.select("name") | Retrieve one column |
Multiple Columns | query.select(["name", "email"]) | Retrieve multiple columns |
Dynamic Columns Array | query.select(columns) | Type-safe dynamic selection |