Driver for Firebird databases
Driver for MySQL databases
Class for connection management
#getQuery
Return an existing query builder instance
Return an existing query builder instance
QueryBuilder
:
The Query Builder object
#init(driverType, connObject, [connLib])
Create a query builder object
Create a query builder object
String
driverType
:
The name of the database type, eg. mysql or pg
Object
connObject
:
A connection object from the database library you are connecting with
[String
]
connLib
:
The name of the db connection library you are using, eg. mysql or mysql2. Optional if the same as driverType
QueryBuilder
:
The Query Builder object
Driver for PostgreSQL databases
Main object that builds SQL queries.
Driver
Driver
:
The syntax driver for the database
Adapter
Adapter
:
The database module adapter for running queries
#delete(table, [where], [callback])
Run the generated delete query
Run the generated delete query
String
table
:
The table to insert into
[Object
]
where
:
Where clause for delete statement
[Function
]
callback
:
Callback for handling response from the database
void
or Promise
:
If no callback is passed, a promise is returned
#end
Closes the database connection for the current adapter
Closes the database connection for the current adapter
void
#from(tableName)
Specify the database table to select from
Specify the database table to select from
String
tableName
:
The table to use for the current query
QueryBuilder
:
The Query Builder object, for chaining
query.from('tableName');
query.from('tableName t'); // Select the table with an alias
#get([table], [limit], [offset], [callback])
Get the results of the compiled query
Get the results of the compiled query
[String
]
table
:
The table to select from
[Number
]
limit
:
A limit for the query
[Number
]
offset
:
An offset for the query
[Function
]
callback
:
A callback for receiving the result
void
or Promise
:
If no callback is passed, a promise is returned
query.get('table_name').then(promiseCallback); // Get all the rows in the table
query.get('table_name', 5, callback); // Get 5 rows from the table
query.get(callback); // Get the results of a query generated with other methods
#groupBy(field)
Group the results by the selected field(s)
Group the results by the selected field(s)
QueryBuilder
:
The Query Builder object, for chaining
#groupEnd
Ends a logical grouping started with one of the groupStart methods
Ends a logical grouping started with one of the groupStart methods
QueryBuilder
:
The Query Builder object, for chaining
#groupStart
Adds an open paren to the current query for logical grouping
Adds an open paren to the current query for logical grouping
QueryBuilder
:
The Query Builder object, for chaining
#having(key, [val])
Add a 'having' clause
Add a 'having' clause
String
or Object
key
:
The name of the field and the comparision operator, or an object
[String
or Number
]
val
:
The value to compare if the value of key is a string
QueryBuilder
:
The Query Builder object, for chaining
#insert(table, [data], [callback])
Run the generated insert query
Run the generated insert query
String
table
:
The table to insert into
[Object
]
data
:
Data to insert, if not already added with the 'set' method
[Function
]
callback
:
Callback for handling response from the database
void
or Promise
:
If no callback is passed, a promise is returned
#insertBatch(table, data, [callback])
Insert multiple sets of rows at a time
Insert multiple sets of rows at a time
String
table
:
The table to insert into
Array
data
:
The array of objects containing data rows to insert
[Function
]
callback
:
Callback for handling database response
void
or Promise
:
If no callback is passed, a promise is returned
query.insertBatch('foo',[{id:1,val:'bar'},{id:2,val:'baz'}], callbackFunction);
query.insertBatch('foo',[{id:1,val:'bar'},{id:2,val:'baz'}])
.then(promiseCallback);
#join(table, cond, [type])
Add a join clause to the query
Add a join clause to the query
String
table
:
The table you are joining
String
cond
:
The join condition.
[String
]
type
(default 'inner'
)
:
The type of join, which defaults to inner
QueryBuilder
:
The Query Builder object, for chaining
#like(field, val, [pos])
Add a 'like/ and like' clause to the query
Add a 'like/ and like' clause to the query
String
field
:
The name of the field to compare to
String
val
:
The value to compare to
[String
]
pos
(default both
)
:
The placement of the wildcard character(s): before, after, or both
QueryBuilder
:
The Query Builder object, for chaining
#limit(limit, [offset])
Put a limit on the query
Put a limit on the query
QueryBuilder
:
The Query Builder object, for chaining
#notLike(field, val, [pos])
Add a 'not like/ and not like' clause to the query
Add a 'not like/ and not like' clause to the query
String
field
:
The name of the field to compare to
String
val
:
The value to compare to
[String
]
pos
(default both
)
:
The placement of the wildcard character(s): before, after, or both
QueryBuilder
:
The Query Builder object, for chaining
#orGroupStart
Adds an open paren to the current query for logical grouping, prefixed with 'OR'
Adds an open paren to the current query for logical grouping, prefixed with 'OR'
QueryBuilder
:
The Query Builder object, for chaining
#orHaving(key, [val])
Add an 'or having' clause
Add an 'or having' clause
String
or Object
key
:
The name of the field and the comparision operator, or an object
[String
or Number
]
val
:
The value to compare if the value of key is a string
QueryBuilder
:
The Query Builder object, for chaining
#orLike(field, val, [pos])
Add an 'or like' clause to the query
Add an 'or like' clause to the query
String
field
:
The name of the field to compare to
String
val
:
The value to compare to
[String
]
pos
(default both
)
:
The placement of the wildcard character(s): before, after, or both
QueryBuilder
:
The Query Builder object, for chaining
#orNotGroupStart
Adds an open paren to the current query for logical grouping, prefixed with 'OR NOT'
Adds an open paren to the current query for logical grouping, prefixed with 'OR NOT'
QueryBuilder
:
The Query Builder object, for chaining
#orNotLike(field, val, [pos])
Add an 'or not like' clause to the query
Add an 'or not like' clause to the query
String
field
:
The name of the field to compare to
String
val
:
The value to compare to
[String
]
pos
(default both
)
:
The placement of the wildcard character(s): before, after, or both
QueryBuilder
:
The Query Builder object, for chaining
#orWhere(key, [val])
Set a 'or where' clause
Set a 'or where' clause
String
or Object
key
:
The name of the field and the comparision operator, or an object
[String
or Number
]
val
:
The value to compare if the value of key is a string
QueryBuilder
:
The Query Builder object, for chaining
#orWhereIn(key, values)
Set a 'or where in' clause
Set a 'or where in' clause
QueryBuilder
:
The Query Builder object, for chaining
#orWhereIsNotNull(field)
Field is not null prefixed with 'OR'
Field is not null prefixed with 'OR'
String
field
:
The name of the field
QueryBuilder
:
The Query Builder object, for chaining
#orWhereIsNull(field)
Field is null prefixed with 'OR'
Field is null prefixed with 'OR'
String
field
:
The name of the field
QueryBuilder
:
The Query Builder object, for chaining
#orWhereNotIn(key, values)
Set a 'or where not in' clause
Set a 'or where not in' clause
QueryBuilder
:
The Query Builder object, for chaining
#orderBy(field, [type])
Order the results by the selected field(s)
Order the results by the selected field(s)
String
field
:
The field(s) to order by
[String
]
type
(default 'ASC'
)
:
The order direction, ASC or DESC
QueryBuilder
:
The Query Builder object, for chaining
#resetQuery
Reset the object state for a new query
Reset the object state for a new query
void
#select(fields)
Specify rows to select in the query
Specify rows to select in the query
QueryBuilder
:
The Query Builder object, for chaining
query.select('foo, bar'); // Select multiple fields with a string
query.select(['foo', 'bar']); // Select multiple fileds with an array
#set(key, [val])
Set values for insertion or updating
Set values for insertion or updating
QueryBuilder
:
The Query Builder object, for chaining
query.set('foo', 'bar'); // Set a key, value pair
query.set({foo:'bar'}); // Set with an object
#update(table, [data], [callback])
Run the generated update query
Run the generated update query
String
table
:
The table to insert into
[Object
]
data
:
Data to insert, if not already added with the 'set' method
[Function
]
callback
:
Callback for handling response from the database
void
or Promise
:
If no callback is passed, a promise is returned
#where(key, [val])
Set a 'where' clause
Set a 'where' clause
String
or Object
key
:
The name of the field and the comparision operator, or an object
[String
or Number
]
val
:
The value to compare if the value of key is a string
QueryBuilder
:
The Query Builder object, for chaining
#whereIn(key, values)
Set a 'where in' clause
Set a 'where in' clause
QueryBuilder
:
The Query Builder object, for chaining
#whereIsNotNull(field)
Specify that a field IS NOT NULL
Specify that a field IS NOT NULL
String
field
:
The name so the field that is not to be null
QueryBuilder
:
The Query Builder object, for chaining
#whereIsNull(field)
Select a field that is Null
Select a field that is Null
String
field
:
The name of the field that has a NULL value
QueryBuilder
:
The Query Builder object, for chaining
#whereNotIn(key, values)
Set a 'where not in' clause
Set a 'where not in' clause
QueryBuilder
:
The Query Builder object, for chaining
Driver for Sqlite databases
Close the current database connection
void
Close the current database connection
void
Run the sql query as a prepared statement
String
sql
:
The sql with placeholders
Array
params
:
The values to insert into the query
[Function
]
callback
:
Callback to run when a response is recieved
void
or Promise
:
Returns a promise if no callback is provided
Run the sql query as a prepared statement
String
sql
:
The sql with placeholders
Array
params
:
The values to insert into the query
[Function
]
callback
:
Callback to run when a response is recieved
void
or Promise
:
Returns a promise if no callback is provided
Run the sql query as a prepared statement
String
sql
:
The sql with placeholders
Array
params
:
The values to insert into the query
[Function
]
callback
:
Callback to run when a response is recieved
void
or Promise
:
Returns a promise if no callback is provided
Run the sql query as a prepared statement
String
sql
:
The sql with placeholders
Array
params
:
The values to insert into the query
[Function
]
callback
:
Callback to run when a response is recieved
void
or Promise
:
Returns a promise if no callback is provided
Run the sql query as a prepared statement
String
sql
:
The sql with placeholders
Array
params
:
The values to insert into the query
[Function
]
callback
:
Callback to run when a response is recieved
void
or Promise
:
Returns a promise if no callback is provided
SQL to insert a group of rows Override default to have better compatibility
String
:
The generated sql statement
SQL to insert a group of rows
void