Skip to content

Method Reference

This is a brief summary of the object methods available.

Database Methods

MethodDescription
connect(options)Connect to the database and return a Database object
disconnect()Disconnect from the database
run(query, values, options)Run a raw SQL query or named query
one(query, values, options)Run a raw SQL query or named query to fetch exactly one row
any(query, values, options)Run a raw SQL query or named query to fetch any single row
all(query, values, options)Run a raw SQL query or named query to fetch all rows
buildStart a query builder chain
select(columns)Start a SELECT query builder chain with a column selection
insert(columns)Start an INSERT query builder chain with a column selection
update(table)Start an UPDATE query builder chain with a table name
delete(columns)Start an DELETE query builder chain with optional column specification
transaction(code)Execute queries in the scope of a transaction
table(name)Lookup a named table and return a Table object

Table Query Methods

MethodDescription
run(query, values, options)Run a raw SQL query or named query
one(query, values, options)Run a raw SQL query or named query to fetch exactly one row
any(query, values, options)Run a raw SQL query or named query to fetch any single row
all(query, values, options)Run a raw SQL query or named query to fetch all rows

Table Insert Methods

MethodDescription
insert(data, options)Insert one or more rows of data
insertOne(data, options)Insert a single row of data
insertAll(array, options)Insert multiple rows of data
insertOneRow(data, options)Insert a single row of data and return the reloaded row
insertAllRows(array, options)Insert multiple rows of data and return an array of reloaded rows
insertRow(data, options)Alias for insertOneRow()
insertRows(array, options)Alias for insertAllRows()
insertOneRecord(data, options)Insert a single row of data and return a record
insertAllRecords(array, options)Insert multiple rows of data and return an array of records
insertRecord(data, options)Alias for insertOneRecord()
insertRecords(array, options)Alias for insertAllRecords()

Table Update Methods

MethodDescription
update(set, where, options)Update one or more rows to set new values where matching criteria
updateOne(set, where, options)Update exactly one row to set new values where matching criteria
updateAny(set, where, options)Update any row to set new values where matching criteria
updateAll(set, where, options)Update all rows to set new values where matching criteria
updateOneRow(set, where, options)Update exactly one row with reload option to return updated row
updateAnyRow(set, where, options)Update any row with reload option to return updated row
updateRow(set, where, options)Alias for updateOneRow()

Table Delete Method

MethodDescription
delete(where)Delete all rows where matching criteria

Table Fetch Methods

MethodDescription
fetch(where, options)Fetch rows where matching criteria
fetchOne(where, options)Fetch exactly one row where matching criteria
fetchAny(where, options)Fetch any row where matching criteria
fetchAll(where, options)Fetch all rows where matching criteria
fetchOneRecord(where, options)Fetch exactly one row where matching criteria and return as a record
fetchAnyRecord(where, options)Fetch any row where matching criteria and return as a record
fetchAllRecords(where, options)Fetch all rows where matching criteria and return as a record
fetchRecord(where, options)Alias for fetchOneRecord()
fetchRecords(where, options)Alias for fetchAllRecords()
oneRow(query, args)Select exactly one row using fetchOne() or one() as appropriate
anyRow(query, args)Select any single row using fetchAny() or any() as appropriate
allRows(query, args)Select all rows using fetchAll() or all() as appropriate
oneRecord(query, args)Select exactly one row using fetchOne() or one() as appropriate and return as a record
anyRecord(query, args)Select any single row using fetchAny() or any() as appropriate and return as a record
allRecords(query, args)Select all rows using fetchAll() or all() as appropriate and return as a record

Other Table Methods

MethodDescription
buildStart a query builder chain
select(columns)Start a query builder chain with column selection and table pre-defined
record(row)Convert a row to a record object
records(rows)Convert an array of rows to an array of record objects

Record Methods

MethodDescription
update(set)Update the record to set new values
delete()Delete the corresponding row from the database
relation(name)Fetch record or records from a named relation