Database class
Provides easy access to the database in relation to the current Session.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
count<
T extends TableRow> ({Expression? where, int? limit, bool useCache = true, Transaction? transaction}) → Future< int> -
Counts the number of rows matching the
where
expression. If omitted, will return the count of all rows in the table. -
delete<
T extends TableRow> (List< T> rows, {Transaction? transaction}) → Future<List< T> > - Deletes all TableRows in the list and returns the deleted rows. This is an atomic operation, meaning that if one of the rows fail to be deleted, none of the rows will be deleted.
-
deleteRow<
T extends TableRow> (T row, {Transaction? transaction}) → Future< T> - Deletes a single TableRow.
-
deleteWhere<
T extends TableRow> ({required Expression where, Transaction? transaction}) → Future< List< T> > -
Deletes all rows matching the
where
expression. -
find<
T extends TableRow> ({Expression? where, int? limit, int? offset, Column? orderBy, List< Order> ? orderByList, bool orderDescending = false, Transaction? transaction, Include? include}) → Future<List< T> > -
Find a list of TableRows from a table, using the provided
where
expression, optionally usinglimit
,offset
, andorderBy
. To order by multiple columns, userorderByList
. Ifwhere
is omitted, all rows in the table will be returned. -
findById<
T extends TableRow> (int id, {Transaction? transaction, Include? include}) → Future< T?> -
Find a single TableRow by its
id
or null if no such row exists. It's often useful to cast the object returned. -
findFirstRow<
T extends TableRow> ({Expression? where, int? offset, Column? orderBy, List< Order> ? orderByList, bool orderDescending = false, Transaction? transaction, Include? include}) → Future<T?> -
Find a single TableRow from a table, using the provided
where
-
insert<
T extends TableRow> (List< T> rows, {Transaction? transaction}) → Future<List< T> > - Inserts all TableRows in the list and returns the inserted rows. This is an atomic operation, meaning that if one of the rows fail to insert, none of the rows will be inserted.
-
insertRow<
T extends TableRow> (T row, {Transaction? transaction}) → Future< T> - Inserts a single TableRow and returns the inserted row.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
testConnection(
) → Future< bool> - Tests the database connection. Returns true if the connection is working. Throws an exception if the connection is not working.
-
toString(
) → String -
A string representation of this object.
inherited
-
transaction<
R> (TransactionFunction< R> transactionFunction, {TransactionSettings? settings}) → Future<R> - Executes a Transaction.
-
unsafeExecute(
String query, {int? timeoutInSeconds, Transaction? transaction, QueryParameters? parameters}) → Future< int> - Executes a single SQL query. Returns the number of rows that were affected by the query.
-
unsafeQuery(
String query, {int? timeoutInSeconds, Transaction? transaction, QueryParameters? parameters}) → Future< DatabaseResult> - Executes a single SQL query. A List of rows represented of another List with columns will be returned.
-
unsafeSimpleExecute(
String query, {int? timeoutInSeconds, Transaction? transaction}) → Future< int> - Executes a single SQL query in simple query mode. Returns the number of rows that were affected by the query.
-
unsafeSimpleQuery(
String query, {int? timeoutInSeconds, Transaction? transaction}) → Future< DatabaseResult> - Executes a single SQL query in simple query mode. A List of rows represented of another List with columns will be returned.
-
update<
T extends TableRow> (List< T> rows, {List<Column> ? columns, Transaction? transaction}) → Future<List< T> > -
Update all TableRows in the list and returns the updated rows. If
columns
is provided, only those columns will be updated. Defaults to all columns. This is an atomic operation, meaning that if one of the rows fail to update, none of the rows will be updated. -
updateRow<
T extends TableRow> (T row, {List< Column> ? columns, Transaction? transaction}) → Future<T> -
Updates a single TableRow. The row needs to have its id set.
Optionally, a list of
columns
can be provided to only update those columns. Defaults to all columns.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited