Select

Prepares a new Selection

Constructor

new Select()

Methods

avg(doParse) → {this}

Averages numerical rows of the first selected column
Parameters:
NameTypeDefaultDescription
doParseBooleanfalseReturn only an integer, not the full query result
Returns:
Type: 
this

count(doParse) → {this}

Counts number of entries of the first selected column
Parameters:
NameTypeDefaultDescription
doParseBooleanfalseReturn 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:
NameTypeAttributesDescription
columnsString<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:
NameTypeDescription
stringStringThe having-clause with possible aggregation and ? representing each values
valuesArray.<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:
NameTypeAttributesDescription
type"LEFT" | "INNER" | "RIGHT" | "FULL OUTER"Join-type
tableStringTable to join on
onOriginalColumnStringColumn name on the original table to check against
onJoinedColumnStringColumn name of the join table to check against
columnsany<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:
NameTypeDescription
numberNumberLimits the query by specified rows
offsetNumberOffset 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:
NameTypeDefaultDescription
columnStringColumn to order by
descBooleanfalseSorty descending
aggregation"MIN" | "MAX" | "COUNT" | "SUM" | "AVG"The aggregation type to use
Returns:
Type: 
this

pagination(page, itemsPerPage) → {this}

Paginates the query
Parameters:
NameTypeDescription
pageNumberThe page to get (Minimum 1)
itemsPerPageNumberHow many items a page should have
Returns:
Type: 
this

selectDatabase(database) → {this}

Selects a database for this query
Parameters:
NameTypeDescription
databaseStringName of the database
Returns:
Type: 
this

sum(doParse) → {this}

Sums numerical rows of the first selected column
Parameters:
NameTypeDefaultDescription
doParseBooleanfalseReturn 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:
NameTypeDescription
stringStringThe where-clause as a string with ? representing each values.
valuesArray.<Any>Array containing values replacing the ? in the string (from left to right)
Returns:
Type: 
this