-
<private> _generateDelete()
-
Generate the final DELETE statement
-
<private> _generateInsert()
-
Generate the final INSERT statement
-
<private> _generateSelect()
-
Generate the final SELECT statement
-
<private> _generateUpdate()
-
Generate the final UPDATE statement
-
delete()
-
Delete row from table
Example 1:
delete()
Returns:
oThis
-
Type
-
object.<self>
-
generate()
-
Generate final query supported by mysql node module
Returns:
-
Type
-
object.<response>
-
group_by()
-
List of fields to be grouped by from table. If called multiple times, group by conditions will be joined by COMMA.
Possible data types:
* Array - list of field names will be joined by comma
* String - list of field names will be used as it is
Example 1:
group_by(['name', 'created_at'])
Example 2:
group_by('name, created_at')
Returns:
oThis
-
Type
-
object.<self>
-
having()
-
List of fields for having clause. If called multiple times, having conditions will be joined by AND.
Possible data types:
* Array - index 0 should have the having sub query and other indexes should have the valued to be replaced in sub query
* String - where sub query, used as it is.
Example 1: Where in array format
having(['MIN(`salary`) < ?', 10])
Example 2: condition in string. Will be used as it is
having('MIN(`salary`) < 10')
Returns:
oThis
-
Type
-
object.<self>
-
insert((object), (object), (object))
-
Insert single record in table. Method can't be called twice on same object
Example 1: Insert in object format.
insert({name: 'ACMA', id: 10})
Parameters:
Name |
Type |
Description |
(object) |
|
insertFields - key and value pairs of columns and values to be inserted |
(object) |
|
insertOptions - |
(object) |
|
[insertOptions.touch] - if true, auto insert created_at and updated_at values. Default is true. |
Returns:
oThis
-
Type
-
object.<self>
-
insertMultiple(insertColumns, insertValues, insertOptions)
-
Insert multiple records in table. Method can't be called twice on same object
Example 1:
insertMultiple(['name', 'symbol'], [['ABC', '123'], ['ABD', '456']])
Parameters:
Name |
Type |
Description |
insertColumns |
array
|
list of columns. also columns are mandatory |
insertValues |
array
|
array of array with values |
insertOptions |
object
|
-
Properties
Name |
Type |
Argument |
Description |
touch |
object
|
<optional>
|
if true, auto insert created_at and updated_at values. Default is true. |
|
Returns:
oThis
-
Type
-
object.<self>
-
limit((number))
-
Limit of records to be fetched. If called multiple times, it will overwrite the previous value
Example 1:
limit(100)
Parameters:
Name |
Type |
Description |
(number) |
|
recordsLimit - limit for select query |
Returns:
oThis
-
Type
-
object.<self>
-
offset((number))
-
Offset for records to be fetched. If called multiple times, it will overwrite the previous value. limit is mandatory for offset
Example 1:
offset(10)
Parameters:
Name |
Type |
Description |
(number) |
|
recordsOffset - offset for select query |
Returns:
oThis
-
Type
-
object.<self>
-
onDuplicate()
-
On Duplicate conditions to be applied to the INSERT query. If called multiple times, conditions will be joined by COMMA.
Possible data types:
* Array - index 0 should have the On Duplicate sub query and other indexes should have the valued to be replaced in sub query
* Object - key and value pairs of columns and values to be joined by COMMA to form On Duplicate sub query
* String - sub query, used as it is.
Example 1: ON DUPLICATE in array format
onDuplicate(['name=? , id=?', 'ACMA', 10])
Example 2: ON DUPLICATE in object format. Conditions will be joined by ,
onDuplicate({name: 'ACMA', id: 10})
Example 3: ON DUPLICATE in string. Will be used as it is
onDuplicate('id=10')
Returns:
oThis
-
Type
-
object.<self>
-
order_by()
-
List of fields to be ordered by from table. If called multiple times, order by conditions will be joined by COMMA.
Possible data types:
* Object - where keys are column names and value is order
* String - order will be used as it is
Example 1:
order_by({'name': 'ASC', 'created_at': 'DESC'})
Example 2:
order_by('name ASC, created_at DESC')
Example 3:
order_by([1, 2, 3])
Returns:
oThis
-
Type
-
object.<self>
-
select()
-
List of fields to be selected from table. If called multiple times, select columns will be joined by COMMA.
Possible data types:
* blank/undefined - '*' will be used to fetch all columns
* Array - list of field names will be joined by comma
* String - list of field names will be used as it is
Example 1: '*' will be used to fetch all columns
select()
Example 2: list of field names in array. Will be joined by comma
select(['name', 'created_at'])
Example 3: list of field names in string. Will be used as it is
select('name, created_at')
Returns:
oThis
-
Type
-
object.<self>
-
update(updateFields, insertOptions)
-
Update columns to be applied to the query. If called multiple times, update fields will be joined by COMMA.
Possible data types:
* Array - index 0 should have the update sub query and other indexes should have the valued to be replaced in sub query
* Object - key and value pairs of columns and values to be joined by COMMA to form update sub query
* String - update sub query, used as it is.
Parameters:
Name |
Type |
Description |
updateFields |
*
|
refer possible data types |
insertOptions |
object
|
-
Properties
Name |
Type |
Argument |
Description |
touch |
object
|
<optional>
|
if true, auto insert created_at and updated_at values. Default is true.
Example 1: update in array format
update(['name=?, id=?', 'ACMA', 10])
Example 2: Update in object format. Fields will be joined by {,}
update({name: 'ACMA', id: 10})
Example 3: Update in string. Will be used as it is
update('id=10') |
|
Returns:
oThis
-
Type
-
object.<self>
-
where()
-
Where conditions to be applied to the query. If called multiple times, where conditions will be joined by AND.
Possible data types:
* Array - index 0 should have the where sub query and other indexes should have the valued to be replaced in sub query
* Object - key and value pairs of columns and values to be joined by AND to form where sub query
* String - where sub query, used as it is.
Example 1: Where in array format
where(['name=? AND id=?', 'ACMA', 10])
Example 2: Where in object format. Conditions will be joined by AND
where({name: 'ACMA', id: 10})
where({name: [1,2,3], id: 10})
Example 3: condition in string. Will be used as it is
where('id=10')
Returns:
oThis
-
Type
-
object.<self>