Constructor
new Select()
Methods
avg(doParse) → {this}
Averages numerical rows of the first selected column
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
doParse | Boolean | false | Return only an integer, not the full query result |
Returns:
- Type:
- this
count(doParse) → {this}
Counts number of entries of the first selected column
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
doParse | Boolean | false | Return only an integer, not the full query result |
Returns:
- Type:
- this
distinct() → {this}
Adds the 'distinct' keyword for this query Should be called on only selected columns. - With 'distinct' only unique values are returned
Returns:
- Type:
- this
(async) execute() → {Any}
Executes the prepared querry
Returns:
- Type:
- Any
group(…columns) → {this}
Groups rows that have the same values into summary rows
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
columns | String | <repeatable> | The columns to group by |
Returns:
- Type:
- this
having(string, values) → {this}
Same as a where-clause, but allows for aggregation - Values should be set as ? in the string and given in left-to-right order via the 'values'-array to minimize the risk of sql-injection - If you are using joins, specify the table and column together: table.column
Parameters:
| Name | Type | Description |
|---|---|---|
string | String | The having-clause with possible aggregation and ? representing each values |
values | Array.<Any> | Array containing values replacing the ? in the string (from left to right) |
Returns:
- Type:
- this
join(type, table, onOriginalColumn, onJoinedColumn, …columns) → {this}
Adds a new join to the querry
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
type | "LEFT" | | Join-type | |
table | String | Table to join on | |
onOriginalColumn | String | Column name on the original table to check against | |
onJoinedColumn | String | Column name of the join table to check against | |
columns | any | <repeatable> | The columns to join. OG-Columns must be set! |
Returns:
- Type:
- this
limit(number, offset) → {this}
Limits the query and specifies an offset
Parameters:
| Name | Type | Description |
|---|---|---|
number | Number | Limits the query by specified rows |
offset | Number | Offset to start at |
Returns:
- Type:
- this
order(column, desc, aggregation) → {this}
Adds a new sort order - Can be used multiple times to order by multiple columns
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
column | String | Column to order by | |
desc | Boolean | false | Sorty descending |
aggregation | "MIN" | | The aggregation type to use |
Returns:
- Type:
- this
pagination(page, itemsPerPage) → {this}
Paginates the query
Parameters:
| Name | Type | Description |
|---|---|---|
page | Number | The page to get (Minimum 1) |
itemsPerPage | Number | How many items a page should have |
Returns:
- Type:
- this
selectDatabase(database) → {this}
Selects a database for this query
Parameters:
| Name | Type | Description |
|---|---|---|
database | String | Name of the database |
Returns:
- Type:
- this
sum(doParse) → {this}
Sums numerical rows of the first selected column
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
doParse | Boolean | false | Return only an integer, not the full query result |
Returns:
- Type:
- this
where(string, values) → {this}
Adds a where-clause to the query - Values should be set as ? in the string and given in left-to-right order via the 'values'-array to minimize the risk of sql-injection - If you are using joins, specify the table and column together: table.column
Parameters:
| Name | Type | Description |
|---|---|---|
string | String | The where-clause as a string with ? representing each values. |
values | Array.<Any> | Array containing values replacing the ? in the string (from left to right) |
Returns:
- Type:
- this