-
-
Notifications
You must be signed in to change notification settings - Fork 1
table.select()
Oxford Harrison edited this page Nov 19, 2024
·
25 revisions
Programmatically perform a SELECT
query.
See related ➞
SELECT
table.select(
spec?: SelectSpec | Callback
): Promise<QueryResult>;
Param | Interfaces | Description |
---|---|---|
spec? |
SelectSpec |
Optional select spec. Can be Callback —a callback function that recieves the underlying SelectStatement instance for manipulation. |
interface SelectSpec {
fields?: string | Field[];
where?: WhereClause;
orderBy?: OrderByClause;
limit?: LimitClause;
offset?: OffsetClause;
leftJoin?: LeftJoinClause;
rightJoin?: RightJoinClause;
innerJoin?: InnerJoinClause;
crossJoin?: CrossJoinClause;
fullJoin?: FullJoinClause;
joins?: (LeftJoinClause | RightJoinClause | InnerJoinClause | CrossJoinClause | FullJoinClause)[];
groupBy?: GroupByClause;
having?: HavingClause;
window?: WindowClause;
}
Param | Interfaces | Description |
---|---|---|
fields? |
Field |
Optional list of fields to select. Defaults to all fields if omitted. |
where? |
WhereClause |
An optional WHERE clause. |
orderBy? |
OrderByClause |
An optional ORDER BY clause. |
limit? |
LimitClause |
An optional LIMIT clause. |
offset? |
OffsetClause |
An optional OFFSET clause. |
leftJoin? |
LeftJoinClause |
An optional LEFT JOIN clause. |
rightJoin? |
RightJoinClause |
An optional RIGHT JOIN clause. |
innerJoin? |
InnerJoinClause |
An optional INNER JOIN clause. |
crossJoin? |
CrossJoinClause |
An optional CROSS JOIN clause. |
fullJoin? |
FullJoinClause |
An optional FULL JOIN clause. |
joins? |
LeftJoinClause RightJoinClause InnerJoinClause CrossJoinClause FullJoinClause
|
An optional list of JOIN clauses. |
groupBy? |
GroupByClause |
An optional GROUP BY clause. |
having? |
HavingClause |
An optional HAVING clause. |
window? |
WindowClause |
An optional WINDOW clause. |
type QueryResult = Array<object> | object;
Type | Interfaces | Description |
---|---|---|
Array<object> |
- | An array of objects—the default query result. |
object |
- | A single object—the result of a find-one query. |
Select specific fields from first 4 records:
const result = await table.select({
fields: ['first_name', 'last_name', 'email'],
limit: 4
});
Select all fields from all records:
const result = await table.select();
See more ➞
SELECT
Find by ID—with actual ID name automatically figured by Linked QL:
const result = await table.select({ where: 4 });
console.log(result); // single result object