Database class
Provides easy access to the database in relation to the current DatabaseSession.
- Available extensions
Properties
- analyzer → DatabaseAnalyzer
-
The analyzer for this database.
latefinal
- dialect → DatabaseDialect
-
The dialect of the database.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- serializationManager → DatabaseSerializationManager
-
The serialization manager to use for the database.
no setter
Methods
-
count<
T extends TableRow> ({Expression? where, int? limit, bool useCache = true, Transaction? transaction}) → Future< int> -
Counts the number of rows matching the
whereexpression. If omitted, will return the count of all rows in the table. -
delete<
T extends TableRow> (List< T> rows, {Column? orderBy, List<Column> ? orderByList, Transaction? transaction, bool noReturn = false}) → Future<List< T> > - Deletes all TableRows in the list and returns the deleted rows.
-
deleteRow<
T extends TableRow> (T row, {Transaction? transaction}) → Future< T> - Deletes a single TableRow.
-
deleteWhere<
T extends TableRow> ({required Expression where, Column? orderBy, List< Column> ? orderByList, Transaction? transaction, bool noReturn = false}) → Future<List< T> > -
Deletes all rows matching the
whereexpression and returns the deleted rows. -
ensureVectorLoaded(
) → Future< void> -
Available on Database, provided by the VectorDatabase extension
Ensures that the vector extension is loaded in the database. This is useful to ensure that vector runtime parameters default values are available. Otherwise, if parameters are queried before the extension is loaded, they will return null, making the behavior unpredictable. -
find<
T extends TableRow> ({Expression? where, int? limit, int? offset, Column? orderBy, List< Column> ? orderByList, Transaction? transaction, Include? include, LockMode? lockMode, LockBehavior? lockBehavior}) → Future<List< T> > - Returns a list of TableRows matching the given query parameters.
-
findById<
T extends TableRow> (Object id, {Transaction? transaction, Include? include, LockMode? lockMode, LockBehavior? lockBehavior}) → Future< T?> -
Finds a single TableRow by its
idor 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< Column> ? orderByList, Transaction? transaction, Include? include, LockMode? lockMode, LockBehavior? lockBehavior}) → Future<T?> - Returns the first matching TableRow matching the given query parameters.
-
insert<
T extends TableRow> (List< T> rows, {Transaction? transaction, bool ignoreConflicts = false, bool noReturn = false}) → 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 fails 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.
-
lockRows<
T extends TableRow> ({required Expression where, required LockMode lockMode, required Transaction transaction, LockBehavior lockBehavior = LockBehavior.wait}) → Future< void> -
Acquires row-level locks on rows matching the
whereexpression without returning the row data. -
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, bool noReturn = false}) → Future<List< T> > -
Updates all TableRows in the list and returns the updated rows. If
columnsis 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. -
updateById<
T extends TableRow> (Object id, {required List< ColumnValue> columnValues, Transaction? transaction}) → Future<T?> -
Updates a single TableRow by its
idwith the specified column values. Returns the updated row or null if no row with the given id exists. -
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
columnscan be provided to only update those columns. Defaults to all columns. -
updateWhere<
T extends TableRow> ({required List< ColumnValue> columnValues, required Expression where, int? limit, int? offset, Column? orderBy, List<Column> ? orderByList, Transaction? transaction, bool noReturn = false}) → Future<List< T> > -
Updates all TableRows matching the
whereexpression with the specified column values. Returns the list of updated rows. -
upsert<
T extends TableRow> (List< T> rows, {required List<Column> conflictColumns, List<Column> ? updateColumns, Expression? updateWhere, Transaction? transaction, bool noReturn = false}) → Future<List< T> > -
Upserts all TableRows in the list and returns the resulting rows.
If a row conflicts on the given
conflictColumns, the existing row is updated with the new values. Otherwise, a new row is inserted. This is an atomic operation. -
upsertRow<
T extends TableRow> (T row, {required List< Column> conflictColumns, List<Column> ? updateColumns, Expression? updateWhere, Transaction? transaction}) → Future<T?> -
Upserts a single TableRow and returns the resulting row.
If the row conflicts on the given
conflictColumns, the existing row is updated. Otherwise, a new row is inserted.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited