RepositoryServerIdMixin<T extends SynquillDataModel<T> > mixin
Mixin providing server ID negotiation capabilities to repositories.
This mixin adds functionality for managing server-generated IDs without modifying user models directly. It uses an internal IdNegotiationService to track temporary client IDs and handle ID replacement when the server assigns different IDs.
- Superclass constraints
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- localOnly → bool
-
Whether this repository is local-only (no remote sync).
no setterinherited
- log → Logger
-
Logger for the repository - must be implemented by concrete classes
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
fetchAllFromLocal(
{QueryParams? queryParams}) → Future< List< T> > -
Fetches all items from the local database.
inherited
-
fetchAllFromLocalWithoutPendingSyncOps(
{QueryParams? queryParams}) → Future< List< T> > -
Fetches all items from the local database, excluding those
with pending sync operations.
inherited
-
fetchFromLocal(
String id, {QueryParams? queryParams}) → Future< T?> -
Fetches an item from the local database.
inherited
-
getTemporaryClientId(
T model) → String? - Get the temporary client ID for a model (if any)
-
hasTemporaryId(
T model) → bool - Check if a model has a temporary ID (awaiting server assignment)
-
initializeIdNegotiationService(
{required bool usesServerGeneratedId}) → void - Initialize the ID negotiation service This should be called in the repository constructor
-
isExistingItem(
T item) → Future< bool> -
Checks if an item with the given ID exists in the local database.
This is a placeholder and should be overridden by concrete repositories.
inherited
-
markAsTemporary(
T model, String temporaryClientId) → void - Mark a model as having a temporary ID before server assignment
-
modelUsesServerGeneratedId(
T model) → bool - Check if a model uses server-generated IDs
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeFromLocalIfExists(
String id) → Future< void> -
Removes an item from the local database if it exists.
inherited
-
replaceIdEverywhere(
T model, String newId) → T - Create a new model instance with a different ID This is used during ID negotiation when server assigns a different ID
-
saveToLocal(
T item, {Map< String, dynamic> ? extra}) → Future<void> -
Saves an item to the local database.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
truncateLocalStorage(
) → Future< void> -
Truncates (clears) all local storage for this model type.
inherited
-
updateLocalCache(
List< T> items) → Future<void> -
Updates the local cache with remote data.
inherited
-
watchAllFromLocal(
{QueryParams? queryParams}) → Stream< List< T> > -
Watches all items from the local database.
inherited
-
watchFromLocal(
String id, {QueryParams? queryParams}) → Stream< T?> -
Watches a single item from the local database by its ID.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited