queueUpdate method
Add update operation to queue
Implementation
Future<void> queueUpdate({
required String collectionName,
required String recordId,
required Map<String, dynamic> data,
}) async {
if (!_isJsonSerializable(data)) {
throw ArgumentError(
'Data is not JSON-serializable. Ensure all values are primitive types, '
'Lists, or Maps containing JSON-serializable values.',
);
}
final operation = SyncOperation()
..collectionName = collectionName
..operationType = 'update'
..payload = jsonEncode(data)
..timestamp = DateTime.now()
..status = 'pending'
..recordId = recordId;
await _localStorage.addToSyncQueue(operation);
_metrics.recordOperationQueued('update');
// Emit event
_onEvent?.call(SyncEvent(
type: SyncEventType.operationQueued,
collectionName: collectionName,
recordId: recordId,
metadata: {'operationType': 'update'},
));
}