DriftLocalStore<T extends HasUpdatedAt, Id> class
Drift-backed LocalStore implementation. Persists items, sync points, and pending operations with scope awareness.
- Implemented types
-
- LocalStore<
T, Id>
- LocalStore<
Constructors
-
DriftLocalStore.new({required LocalDriftDatabase db, required Id idOf(T), required String idToString(Id), required Id idFromString(String), required Map<
String, dynamic> toJson(T), required T fromJson(Map<String, dynamic> ), bool supportsSoftDelete = true})
Properties
- db → LocalDriftDatabase
-
final
-
fromJson
→ T Function(Map<
String, dynamic> ) -
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- idFromString → Id Function(String)
-
final
- idOf → Id Function(T)
-
final
- idToString → String Function(Id)
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- supportsSoftDelete → bool
-
Whether this store performs soft delete (set deletedAt) instead of hard delete.
final
-
toJson
→ Map<
String, dynamic> Function(T) -
final
Methods
-
approxCacheSizeBytes(
{SyncScope? scope}) → Future< int> -
Cache management APIs
Returns an approximate size of the local cache in bytes. When
scope
is provided, the size is calculated only for that scope; otherwise it is for the whole store.override -
clearCache(
{SyncScope? scope}) → Future< void> -
Clears cached data. When
scope
is provided, clears only that scope; otherwise clears all data. Implementations should also clear sync points and pending operations for the cleared scope(s).override -
clearPendingOps(
SyncScope scope, List< String> opIds) → Future<void> -
override
-
deleteMany(
SyncScope scope, List< Id> ids) → Future<void> -
Delete semantics within the given
scope
:override -
deleteWhere(
SyncScope scope, QuerySpec spec) → Future< int> -
Delete items that match
spec
within thescope
. Applies soft/hard delete semantics in the same way as deleteMany. Returns the number of affected rows if available, else -1.override -
enqueuePendingOp(
PendingOp< T, Id> op) → Future<void> -
override
-
getById(
Id id) → Future< T?> -
override
-
getCacheSizeLimitBytes(
) → Future< int?> -
Returns the cache size limit in bytes, or null if unlimited.
override
-
getPendingOps(
SyncScope scope) → Future< List< PendingOp< >T, Id> > -
override
-
getSyncPoint(
SyncScope scope) → Future< DateTime?> -
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
query(
SyncScope scope) → Future< List< T> > -
override
-
querySince(
SyncScope scope, DateTime since) → Future< List< T> > -
override
-
queryWith(
SyncScope scope, QuerySpec spec) → Future< List< T> > -
Query with general DB-like filters, ordering and pagination within a scope.
This does not escape the scope and respects soft-delete semantics.
override
-
saveSyncPoint(
SyncScope scope, DateTime timestamp) → Future< void> -
override
-
setCacheSizeLimitBytes(
int? bytes) → Future< void> -
Sets the cache size limit in bytes. When null, no limit is enforced.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
updateWhere(
SyncScope scope, QuerySpec spec, List< T> newValues) → Future<int> -
Update items that match
spec
within thescope
. For stores that support soft delete, implementations SHOULD avoid updating tombstoned rows. Returns the number of affected rows if available, else -1.override -
upsertMany(
SyncScope scope, List< T> items) → Future<void> -
Upsert items that belong to the given
scope
.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited