NetCoreSyncClient mixin

The main mixin class that provides the synchronization method and replacement methods for the standard Moor's method calls that is compatible with synchronization.

This class should be mixed with the main Moor database class (the class that is annotated with @UseMoor). There's also a mixin class called NetCoreSyncClientUser (which created during code generation) that also should be mixed with the database class. For example:

@UseMoor(
  tables: [
    // ...some table classes here...
    NetCoreSyncKnowledges,
  ],
)
class Database extends _$Database
    with NetCoreSyncClient, NetCoreSyncClientUser {
// ... class code here ...
}

Later after the database class has been instantiated in code, it should call the framework initialization method called netCoreSyncInitialize(). Read the Client Side Initialization in the netcoresync_moor documentation for more details.

NOTE: The netCoreSyncInitialize() method is created during code generation, which in turns calls the netCoreSyncInitializeClient(), and the netCoreSyncInitializeUser() method that is generated inside the NetCoreSyncClientUser class.

Properties

allSchemaEntities Iterable<DatabaseSchemaEntity>
A list of all DatabaseSchemaEntity that are specified in this database.
no setterinherited
allTables Iterable<TableInfo<Table, dynamic>>
A list of tables specified in this database.
no setterinherited
attachedDatabase → GeneratedDatabase
The database class that this user is attached to.
no setterinherited
connection → DatabaseConnection
The database connection used by this DatabaseConnectionUser.
finalinherited
dataAccess → DataAccess<GeneratedDatabase>
(This property is used internally, no need to use it directly)
no setter
executor → QueryExecutor
The executor to use when queries are executed.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
migration → MigrationStrategy
Defines the migration strategy that will determine how to deal with an increasing schemaVersion. The default value only supports creating the database by creating all tables known in this database. When you have changes in your schema, you'll need a custom migration strategy to create the new tables or change the columns.
no setterinherited
netCoreSyncInitialized bool
Indicates whether the framework has been initialized (by calling netCoreSyncInitialize()) or not.
no setter
netCoreSyncResolvedEngine → dynamic
(This property is used internally, no need to use it directly)
no setter
resolvedEngine → DatabaseConnectionUser
A, potentially more specific, database engine based on the Zone context.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
schemaVersion int
Specify the schema version of your database. Whenever you change or add tables, you should bump this field and provide a migration strategy.
no setterinherited
streamQueries → StreamQueryStore
Manages active streams from select statements.
no setterinherited
streamUpdateRules → StreamQueryUpdateRules
The collection of update rules contains information on how updates on tables result in other updates, for instance due to a trigger.
no setterinherited
typeSystem → SqlTypeSystem
The type system to use with this database. The type system is responsible for mapping Dart objects into sql expressions and vice-versa.
no setterinherited

Methods

$expandVar(int start, int amount) String
Used by generated code to expand array variables.
inherited
$write(Component component, {bool? hasMultipleTables, int? startIndex}) → GenerationContext
Will be used by generated code to resolve inline Dart components in sql.
inherited
$writeInsertable(TableInfo<Table, dynamic> table, Insertable insertable, {int? startIndex}) → GenerationContext
Writes column names and VALUES for an insert statement.
inherited
alias<T extends Table, D>(TableInfo<T, D> table, String alias) → T
Creates a copy of the table with an alias so that it can be used in the same query more than once.
inherited
batch(_BatchRunner runInBatch) Future<void>
Runs statements inside a batch.
inherited
beforeOpen(QueryExecutor executor, OpeningDetails details) Future<void>
A callbacks that runs after the database connection has been established, but before any other query is sent.
inherited
close() Future<void>
Closes this database and releases associated resources.
inherited
createMigrator() → Migrator
Creates a Migrator with the provided query executor. Migrators generate sql statements to create or drop tables.
inherited
createStream(QueryStreamFetcher stmt) Stream<List<Map<String, Object?>>>
Creates and auto-updating stream from the given select statement. This method should not be used directly.
inherited
customInsert(String query, {List<Variable> variables = const [], Set<TableInfo<Table, dynamic>>? updates}) Future<int>
Executes a custom insert statement and returns the last inserted rowid.
inherited
customSelect(String query, {List<Variable> variables = const [], Set<ResultSetImplementation> readsFrom = const {}}) → Selectable<QueryRow>
Creates a custom select statement from the given sql query. To run the query once, use Selectable.get. For an auto-updating streams, set the set of tables the ready readsFrom and use Selectable.watch. If you know the query will never emit more than one row, you can also use getSingle and SelectableUtils.watchSingle which return the item directly without wrapping it into a list.
inherited
customSelectQuery(String query, {List<Variable> variables = const [], Set<ResultSetImplementation> readsFrom = const {}}) → Selectable<QueryRow>
Creates a custom select statement from the given sql query. To run the query once, use Selectable.get. For an auto-updating streams, set the set of tables the ready readsFrom and use Selectable.watch. If you know the query will never emit more than one row, you can also use getSingle and watchSingle which return the item directly without wrapping it into a list.
inherited
customStatement(String statement, [List? args]) Future<void>
Executes the custom sql statement on the database.
inherited
customUpdate(String query, {List<Variable> variables = const [], Set<TableInfo<Table, dynamic>>? updates, UpdateKind? updateKind}) Future<int>
Executes a custom delete or update statement and returns the amount of rows that have been changed. You can use the updates parameter so that drift knows which tables are affected by your query. All select streams that depend on a table specified there will then update their data. For more accurate results, you can also set the updateKind parameter to UpdateKind.delete or UpdateKind.update. This is optional, but can improve the accuracy of query updates, especially when using triggers.
inherited
customWriteReturning(String query, {List<Variable> variables = const [], Set<TableInfo<Table, dynamic>>? updates, UpdateKind? updateKind}) Future<List<QueryRow>>
Runs a INSERT, UPDATE or DELETE statement returning rows.
inherited
delete<T extends Table, D>(TableInfo<T, D> table) → DeleteStatement<T, D>
Starts a DeleteStatement that can be used to delete rows from a table.
inherited
doWhenOpened<T>(FutureOr<T> fn(QueryExecutor e)) Future<T>
Performs the async fn after this executor is ready, or directly if it's already ready.
inherited
from<T extends HasResultSet, D>(ResultSetImplementation<T, D> table) → TableOrViewOperations<T, D>
Captures a table or view for easier subsequent operations.
inherited
into<T extends Table, D>(TableInfo<T, D> table) → InsertStatement<T, D>
Starts an InsertStatement for a given table. You can use that statement to write data into the table by using InsertStatement.insert.
inherited
markTablesUpdated(Iterable<TableInfo<Table, dynamic>> tables) → void
Marks the tables as updated.
inherited
netCoreSyncAllSyncIds() String
(This method is used internally, no need to use it directly)
netCoreSyncGetActiveSyncId() String?
Get the active syncId from the assigned SyncIdInfo.
netCoreSyncGetSyncIdInfo() SyncIdInfo?
Get the currently assigned SyncIdInfo in the framework. This will return null if the netCoreSyncSetSyncIdInfo() method hasn't been called.
netCoreSyncInitializeClient(NetCoreSyncEngine engine) Future<void>
One of the initialization methods that is invoked by the netCoreSyncInitialize() call.
netCoreSyncSetActiveSyncId(String value) → void
Set the active syncId from the assigned SyncIdInfo.
netCoreSyncSetLogger(void logger(Object? object)) → void
Assign a function handler which receives the object parameter, where object is a log data generated by the framework. This can be used to setup a custom logger in the project.
netCoreSyncSetSyncIdInfo(SyncIdInfo value) → void
Set the currently active SyncIdInfo.
netCoreSyncSynchronize({required String url, SyncEvent? syncEvent, SyncResultLogLevel syncResultLogLevel = SyncResultLogLevel.fullData, Map<String, dynamic> customInfo = const {}}) Future<SyncResult>
Starts the synchronization process.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyUpdates(Set<TableUpdate> updates) → void
Dispatches the set of updates to the stream query manager.
inherited
select<T extends HasResultSet, R>(ResultSetImplementation<T, R> table, {bool distinct = false}) → SimpleSelectStatement<T, R>
Starts a query on the given table.
inherited
selectOnly<T extends HasResultSet, R>(ResultSetImplementation<T, R> table, {bool distinct = false, bool includeJoinedTableColumns = true}) → JoinedSelectStatement<T, R>
Starts a complex statement on table that doesn't necessarily use all of table's columns.
inherited
syncDelete<T extends Table, D>(TableInfo<T, D> table) → SyncDeleteStatement<T, D>
The replacement method for Moor's delete(). Use this method to ensure compatibility with the synchronization process.
syncInto<T extends Table, D>(TableInfo<T, D> table) → SyncInsertStatement<T, D>
The replacement method for Moor's into(). Use this method to ensure compatibility with the synchronization process.
syncSelect<T extends HasResultSet, R>(SyncBaseTable<T, R> table, {bool distinct = false}) → SyncSimpleSelectStatement<T, R>
The replacement method for Moor's select(). Use this method to ensure compatibility with the synchronization process.
syncSelectOnly<T extends HasResultSet, R>(SyncBaseTable<T, R> table, {bool distinct = false}) → SyncJoinedSelectStatement<T, R>
The replacement method for Moor's selectOnly(). Use this method to ensure compatibility with the synchronization process.
syncUpdate<T extends Table, D>(TableInfo<T, D> table) → SyncUpdateStatement<T, D>
The replacement method for Moor's update(). Use this method to ensure compatibility with the synchronization process.
tableUpdates([TableUpdateQuery query = const TableUpdateQuery.any()]) Stream<Set<TableUpdate>>
Listen for table updates reported through notifyUpdates.
inherited
toString() String
A string representation of this object.
inherited
transaction<T>(Future<T> action()) Future<T>
Executes action in a transaction, which means that all its queries and updates will be called atomically.
inherited
update<Tbl extends Table, R>(TableInfo<Tbl, R> table) → UpdateStatement<Tbl, R>
Starts an UpdateStatement for the given table. You can use that statement to update individual rows in that table by setting a where clause on that table and then use UpdateStatement.write.
inherited

Operators

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