NativeDatabase class

A drift database implementation based on dart:ffi, running directly in a Dart VM or an AOT compiled Dart/Flutter application.

Inheritance
Available extensions

Constructors

NativeDatabase(File file, {bool logStatements = false, DatabaseSetup? setup, SqliteResolver sqlite3 = _NativeDelegate._defaultResolver, bool enableMigrations = true, bool cachePreparedStatements = _cacheStatementsByDefault})
Creates a database that will store its result in the file, creating it if it doesn't exist.
factory
NativeDatabase.memory({bool logStatements = false, SqliteResolver sqlite3 = _NativeDelegate._defaultResolver, DatabaseSetup? setup, bool cachePreparedStatements = _cacheStatementsByDefault})
Creates an in-memory database won't persist its changes on disk.
factory
NativeDatabase.opened(Database database, {bool logStatements = false, DatabaseSetup? setup, bool closeUnderlyingOnClose = true, bool enableMigrations = true, bool cachePreparedStatements = _cacheStatementsByDefault})
Creates a drift executor for an opened database from the sqlite3 package.
factory

Properties

delegate → DatabaseDelegate
The DatabaseDelegate to send queries to.
finalinherited
dialect → SqlDialect
The SqlDialect to use for this database engine.
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
impl → QueryDelegate
no setterinherited
isSequential → bool
finalinherited
logStatements ↔ bool
getter/setter pairinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

beginExclusive() → QueryExecutor
Returns a new QueryExecutor that, when first opened, takes an exclusive lock over this executor and prevents queries from running until it is closed.
inherited
beginTransaction() → TransactionExecutor
Starts a TransactionExecutor.
inherited
beginTransactionInContext(_BaseExecutor context) → TransactionExecutor
inherited
close() → Future<void>
Closes this database connection and releases all resources associated with it. Implementations should also handle close calls in a state where the database isn't open.
inherited
ensureOpen(QueryExecutorUser user) → Future<bool>
Opens the executor, if it has not yet been opened.
inherited
externalExecutor(QueryDelegate delegate) → QueryExecutor
Returns a QueryExecutor delegating calls to another QueryDelegate.
inherited
interceptWith(QueryInterceptor interceptor) → QueryExecutor

Available on QueryExecutor, provided by the ApplyInterceptor extension

Returns a QueryExecutor that will use this executor internally, but with calls intercepted by the given interceptor.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
runBatched(BatchedStatements statements) → Future<void>
Prepares and runs statements.
inherited
runCustom(String statement, [List<Object?>? args]) → Future<void>
Runs a custom SQL statement without any variables. The result of that statement will be ignored.
inherited
runDelete(String statement, List<Object?> args) → Future<int>
Runs an delete statement and returns how many rows where affected.
inherited
runInsert(String statement, List<Object?> args) → Future<int>
Runs an insert statement with the given variables. Returns the row id or the auto_increment id of the inserted row.
inherited
runSelect(String statement, List<Object?> args) → Future<List<Map<String, Object?>>>
Runs a select statement with the given variables and returns the raw results.
inherited
runUpdate(String statement, List<Object?> args) → Future<int>
Runs an update statement with the given variables and returns how many rows where affected.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

closeExistingInstances({SqliteResolver sqlite3 = _NativeDelegate._defaultResolver}) → Future<void>
Disposes resources allocated by all NativeDatabase instances of this process.
createBackgroundConnection(File file, {bool logStatements = false, bool isolateDebugLog = false, DatabaseSetup? setup, SqliteResolver sqlite3 = _NativeDelegate._defaultResolver, IsolateSetup? isolateSetup, bool enableMigrations = true, bool cachePreparedStatements = _cacheStatementsByDefault, int readPool = _defaultReadPoolSize}) → DatabaseConnection
Like createInBackground, except that it returns the whole DatabaseConnection instead of just the executor.
createInBackground(File file, {bool logStatements = false, bool cachePreparedStatements = _cacheStatementsByDefault, DatabaseSetup? setup, SqliteResolver sqlite3 = _NativeDelegate._defaultResolver, bool enableMigrations = true, IsolateSetup? isolateSetup, int readPool = _defaultReadPoolSize}) → QueryExecutor
Creates a database storing its result in file.