LocalAdapter<T extends DatumEntityBase> class
abstract
Local storage adapter abstraction that provides access to offline data.
Constructors
Properties
Methods
-
addPendingOperation(
String userId, DatumSyncOperation< T> operation) → Future<void> - Add a new pending operation to the queue.
-
changeStream(
) → Stream< DatumChangeDetail< ?T> > - Stream of changes that occur in the local storage. Return null if the adapter doesn't support change notifications.
-
checkHealth(
) → Future< AdapterHealthStatus> - Checks the health of the local adapter.
-
clear(
) → Future< void> - Remove all data from the adapter.
-
clearUserData(
String userId) → Future< void> - Remove all data for a specific user.
-
create(
T entity) → Future< void> - Create a new entity.
-
delete(
String id, {String? userId}) → Future< bool> -
Remove an entity. Returns
trueif an item was deleted. -
dispose(
) → Future< void> - Dispose of underlying resources (e.g., close database connections).
-
fetchRelated<
R extends DatumEntityBase> (RelationalDatumEntity parent, String relationName, ) → Future< List< R> > - Fetches related entities based on the relationship definitions from the local source.
-
getAllRawData(
{String? userId}) → Future< List< Map< >String, dynamic> > - Fetch all data for a user as a list of raw maps. This is used during schema migrations to avoid deserialization issues.
-
getAllUserIds(
) → Future< List< String> > - Fetch all unique user IDs that have data stored locally.
-
getLastSyncResult(
String userId) → Future< DatumSyncResult< T> ?> - Retrieves the result of the last synchronization for a user.
-
getPendingOperations(
String userId) → Future< List< DatumSyncOperation< >T> > - Get all pending sync operations.
-
getStorageSize(
{String? userId}) → Future< int> - Returns the storage size in bytes for a given user.
-
getStoredSchemaVersion(
) → Future< int> - Retrieve the schema version stored in the database. Should return 0 if none.
-
getSyncMetadata(
String userId) → Future< DatumSyncMetadata?> - Retrieve metadata about the user's sync state.
-
initialize(
) → Future< void> - Initializes the local storage (e.g., opens databases/boxes).
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
overwriteAllRawData(
List< Map< data, {String? userId}) → Future<String, dynamic> >void> - Overwrite all existing data with a new set of raw data maps. This is used during schema migrations after transforming the data.
-
patch(
{required String id, required Map< String, dynamic> delta, String? userId}) → Future<T> - Apply a partial update ("patch") to an existing entity.
-
query(
DatumQuery query, {String? userId}) → Future< List< T> > - Executes a one-time query against the local data source.
-
read(
String id, {String? userId}) → Future< T?> - Fetch a single item by its ID.
-
readAll(
{String? userId}) → Future< List< T> > - Fetch all items.
-
readAllPaginated(
PaginationConfig config, {String? userId}) → Future< PaginatedResult< T> > - Fetch a paginated list of items.
-
readByIds(
List< String> ids, {required String userId}) → Future<Map< String, T> > - Fetch multiple items by their IDs.
-
removePendingOperation(
String operationId) → Future< void> - Remove a pending operation from the queue after it has been synced.
-
saveLastSyncResult(
String userId, DatumSyncResult< T> result) → Future<void> - Saves the result of the last synchronization for a user.
-
schemaVersionStream(
) → Stream< int> ? - A stream that emits when the schema version changes.
-
setStoredSchemaVersion(
int version) → Future< void> - Persist the new schema version to the database.
-
toString(
) → String -
A string representation of this object.
inherited
-
transaction<
R> (Future< R> action()) → Future<R> - Executes a block of code within a single atomic transaction.
-
update(
T entity) → Future< void> - Update an existing entity.
-
updateSyncMetadata(
DatumSyncMetadata metadata, String userId) → Future< void> - Persist updated sync state metadata.
-
watchAll(
{String? userId, bool includeInitialData = true}) → Stream< List< ?T> > - Watch all items, emitting a new list on any change.
-
watchAllPaginated(
PaginationConfig config, {String? userId}) → Stream< PaginatedResult< ?T> > - Watch a paginated list of items. Return null if the adapter doesn't support reactive queries.
-
watchById(
String id, {String? userId}) → Stream< T?> ? - Watch a single item by its ID, emitting the item on change or null if deleted. Return null if the adapter doesn't support reactive queries.
-
watchCount(
{DatumQuery? query, String? userId}) → Stream< int> ? - Watch the total count of entities, optionally matching a query. Return null if the adapter does not support this feature.
-
watchFirst(
{DatumQuery? query, String? userId}) → Stream< T?> ? - Watch the first entity matching a query, optionally sorted. Return null if the adapter does not support this feature.
-
watchQuery(
DatumQuery query, {String? userId}) → Stream< List< ?T> > - Watch a subset of items matching a query. Return null if the adapter doesn't support reactive queries.
-
watchRelated<
R extends DatumEntityBase> (RelationalDatumEntity parent, String relationName, ) → Stream< List< ?R> > - Reactively watches related entities.
-
watchStorageSize(
{String? userId}) → Stream< int>
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
defaultWatchStorageSize<
T extends DatumEntityBase> (LocalAdapter< T> adapter, {String? userId}) → Stream<int> - Reactively watches the storage size in bytes for a given user.