The default column name for row identifier, usually used as primary and auto-incrementing key.
The default column name for row create timestamp.
The default column name for row delete timestamp.
The default column name for row update timestamp.
Executes a count query (SELECT COUNT({countBy}) ...).
The function accepts the same options with findAll except for
pagination
with an additional option:
countBy
: the (count expression)knex-countThe options for select query
A Row object or null
A convenience function to findAll for retrieving one Row.
If there are no row that matches the query, the return value will be null
.
The function accepts the same options with findAll, except for
pagination
.
The options for select query
A Row object or null
Performs a select query and return an array of Row objects.
Options:
conn
(required): the Knex connection object used for creating the querytableName
(required): the table namewhere
: the (where argument)knex-where for the queryincludeDeleted
: whether to skip adding time deleted timestamp query (WHERE {includeDeletedCol} IS NULL
) (default: false
)includeDeletedCol
: the name of time deleted timestamp column (default: TIME_DELETED_COL)pagination
: whether to add limit-offset in query for paginationpage
: the page number to be retrieved (default: 1
)limit
: the maximum number of rows in a page (default: DEFAULT_PAGINATION_LIMIT)before
: a function that will be called with the resulting query object to perform further modifications if necessaryThe includeDeleted
flag defaults to true
because it is assumed that
most findAll
queries will query tables with a soft-delete timestamp column.
If this is not the case, you should explicitly add includeDeleted: false
.
The before
function can be used as 'escape hatch' to add further function
calls to the resulting query builder object, such as .orderBy()
.
The options for select query
An array of Row objects (possibly empty)
Inserts a single row using INSERT query.
In some supported databases (MySQL, SQLite), if the table has auto-increment column, the value of the column will be returned. Otherwise, the return value should be considered unknown, as different database drivers may behave differently.
Options:
conn
(required): the Knex connection object used for creating the queryThe table name for new rows to be inserted
Row data to be inserted
The options for select query
Inserts multiple rows using INSERT query.
Options:
conn
(required): the Knex connection object used for creating the queryThe table name for new rows to be inserted
Array of row data to be inserted
The options for select query
Generated using TypeDoc
This type represents any Knex interfaces that can be used for creating a query:
This is particularly useful to create function that can work with both regular connection and transaction: