Class: Select

Select

Represents a SELECT query.

Constructor

new Select(from)

Initialize the query using a From instance.
Parameters:
Name Type Description
from From A from instance.
Source:

Extends

Members

database

Properties:
Name Type Description
database Database A database instance.
escaper Escaper An instance of an Escaper class that can escape query parts.
queryExecuter QueryExecuter An instance of a QueryExecuter that can execute CRUD operations.
Inherited From:
Source:

Methods

buildQuery() → {Query~QueryMeta}

Build the query.
Inherited From:
Source:
Returns:
The string-representation of the query to execute along with any query parameters.
Type
Query~QueryMeta

execute() → {Promise.<object>}

Execute the query.
Source:
Returns:
A promise that shall be resolved with the normalized query results as an object. The object will contain a key for each top-level table mapping. If an error occurs while executing the query, the returned promise shall be rejected with the unmodified error.
Type
Promise.<object>

orderBy(…metas) → {this}

Order by one or more columns. This function is variadic.
Parameters:
Name Type Attributes Description
metas string | object <repeatable>
A list of fully-qualified column names in the form <table-alias>.<column-name>, or an array of objects with the following properties.
Properties
Name Type Description
column string The fully-qualified column name.
dir string The sort direction; either "ASC" or "DESC."
Source:
Returns:
Type
this

select(…cols) → {this}

Select columns manually.
Parameters:
Name Type Attributes Description
cols object | string <repeatable>
An optional set of columns to select. Each argument can either be a fully-qualified column name in the form <table-alias>.<column-name>, or an object with the following properties below. If no columns are specified, then all columns are selected.
col.column string The fully-qualified column name.
col.mapTo string The name of the property that the column should be mapped to in the resulting normalized object. @param
col.convert function A converter function that takes a single value from the database and transforms it. For example, a function that converts a bit from the database to a boolean value.
Source:
Returns:
Type
this

selectAll() → {this}

Select all columns, which is the default if no columns are specified. This function gets called in execute and in toString if no columns are selected.
Source:
Returns:
Type
this

toString() → {string}

Get the SQL that represents the query.
Source:
Returns:
The SQL representing the select statement.
Type
string