-
Notifications
You must be signed in to change notification settings - Fork 0
SQL
A collection of SQL Utilities
Kind: global class
-
SQL
- Callers
-
Statics
-
.PLACEHOLD(key)
⇒RegExp
-
.FORMAT(query, values)
⇒string
-
.CLAUSE(column, operator, condition, prefix)
⇒string
-
.TYPE(field, next)
⇒mysql.parser
-
.PAGE(vals, threshold)
⇒Object
-
.JOIN(vals, filteropt, coalesceopt, convertopt)
⇒string
-
.LIST(vals, filtersopt, coalescesopt, convertersopt)
⇒Array<string>
-
.BRKT(val, brackets, join)
⇒string
-
.COALESCE()
⇒string
-
.CONCAT(...args)
⇒string
-
.CONCAT_WS(separator, ...args)
⇒string
-
.SOCKET(optionsopt)
⇒string
-
.LIMIT(lmt)
⇒string
-
.OFFSET(ofs)
⇒string
-
SQL.QRY(instatiateopt)
⇒ QRY
Instantiates a new QRY
object, unless otherwise specified
Param | Type | Default | Description |
---|---|---|---|
instatiate opt | boolean |
true |
if false , does NOT instatiate the QRY
|
SQL.SLC(...columnsopt)
⇒ QRY
Begin a SELECT
statement
Param | Type | Description |
---|---|---|
...columns opt |
string | Object.<string, string>
|
The columns toSELECT
|
SQL.INS(table, ...columns)
⇒ QRY
Begin a INSERT
statement
Param | Type | Description |
---|---|---|
table | string |
The table recieving INSERTS
|
...columns | string |
The columns recieving VALUES
|
SQL.UPD(table, ...options)
⇒ QRY
Begin a UPDATE
statement
Param | Type | Description |
---|---|---|
table | string |
The table recieving UPDATES
|
...options | string |
An optional identifer and database for the table |
SQL.DEL()
⇒ QRY
Begin a DELETE
statement
Creates a regex
pattern to match a query-template placeholder
-
Kind: static method of
SQL
-
Returns:
RegExp
- Theregex
pattern
Param | Type | Description |
---|---|---|
key | string |
The placeholder's name |
Takes a query-template and replaces the placeholders
with the values specified
-
Kind: static method of
SQL
-
Returns:
string
- The formattedSQL
query
Param | Type | Description |
---|---|---|
query | string |
An SQL query-template. This utilizes :NAME: placeholders |
values | Object.<string, (string|number)> |
The values to place into the query |
Formats a clause for use in a SQL
query
-
Kind: static method of
SQL
-
Returns:
string
- The formattedSQL
clause
Param | Type | Description |
---|---|---|
column | string |
The column-name this clause pertains to |
operator | string |
The comparison operator (= |
condition | string |
The value the column should conform to |
prefix | string |
The type of clause (WHERE |
A default type-parser for SQL result columns
-
Kind: static method of
SQL
-
Returns:
mysql.parser
- The next field'sparser
Param | Type | Description |
---|---|---|
field | mysql.Field |
A MySQL .Field object |
next | mysql.parser |
The next Field
|
Restricts a pagination object to positive numbers and any specified thresholds
-
Kind: static method of
SQL
-
Returns:
Object
- The restricted pagination object
Param | Type | Description |
---|---|---|
vals | Object |
A pagination object, specifying a page number & result limit |
threshold | Object |
The page & number restrictions for the object |
A reducer, which filters, coalesces, converts (transforms), and joins delimited string to build a complex query-clause
-
Kind: static method of
SQL
-
Returns:
string
- The transformed query-clause
Param | Type | Description |
---|---|---|
vals | string |
Either a string or array of strings to include in the clause. Each subsequent filter/coalesce/converter will be applied to each string |
filter opt | TFilter |
A TFilter that will trickle down to the matching index of the coalesce /converter
|
coalesce opt | TCoalesce |
A TCoalesce objects that will trickle down to the matching index of the converter
|
convert opt | CBConvert |
A CBConvert to handle custom transformationsmatching the index of the corresponding filter object. |
A reducer, which filters, coalesces, converts (transforms), and joins a list of delimited string tobuild a complex Array of query-clauses
-
Kind: static method of
SQL
-
Returns:
Array<string>
- The transformed Array of query-clauses
Param | Type | Description |
---|---|---|
vals |
string | Array<string>
|
Either a string or array of strings to include in the clause. Each subsequent filter/coalesce/converter will be applied to each string |
filters opt |
TFilter | Array<TFilter>
|
An array of TFilters that will trickle down to the matching index of the coalesce /converters
|
coalesces opt |
TCoalesce | Array<TCoalesce>
|
An array of TCoalesces objects that will trickle down to the matching index of the converters
|
converters opt |
CBConvert | Array<CBConvert>
|
An array of CBConverts to handle custom transformations matching the index of the corresponding filter object. |
Concatenates an Array of values, separated by a specified string, and finally, wrapped in specifiedbrackets
-
Kind: static method of
SQL
-
Returns:
string
- The formatted expression
Param | Type | Description |
---|---|---|
val | Array<string> |
An array of values to wrap in brackets |
brackets | Array<string> |
An array (length<=2) specifiying the opening and closing brackets |
join | string |
The string to separate the concatenations |
Not implemented yet.
-
Kind: static method of
SQL
Creates an CONCAT
expression for use in a SQL
query
-
Kind: static method of
SQL
-
Returns:
string
- The formatted expression
Param | Type | Description |
---|---|---|
...args |
string | number
|
The strings to concatenate |
Creates an CONCAT_WS
expression for use in a SQL
query
-
Kind: static method of
SQL
-
Returns:
string
- The formatted expression
Param | Type | Description |
---|---|---|
separator | string |
The string to separate the concatenations |
...args |
string | number
|
The strings to concatenate |
Allows you to create SocketLinks
in a SQL
query
-
Kind: static method of
SQL
-
Returns:
string
- A columnSELECT
statement that formatsSocketLink
string within aSQL
query
Param | Type | Default |
---|---|---|
options opt | Object |
{link:"",columns:null,escapes:1} |
Creates an LIMIT
clause for use in a SQL
query
-
Kind: static method of
SQL
-
Returns:
string
- The formatted clause
Param | Type | Description |
---|---|---|
limit | number |
The limit value |
Creates an OFFSET
clause for use in a SQL
query
-
Kind: static method of
SQL
-
Returns:
string
- The formatted clause
Param | Type | Description |
---|---|---|
** offset** | number |
The offset value |
Copyright © 2018 DFFRNT Innovation Inc. All rights reserved