updateDocument<ID extends Object?> method
Updates data on the document. Data will be merged with any existing document data.
If no document exists yet, the update will fail.
Implementation
@override
Future<void> updateDocument<ID extends Object?>(
String collectionPath, ID documentId, Map<String, Object?> data) async {
final storage = await getStorage(collectionPath);
final existing =
storage.read(documentId.toString()) as Map<String, Object?>?;
if (existing == null) {
throw 'GetStorageDelegate.update: there is no doc to update (id=$documentId)';
} else {
return storage.write(
documentId.toString(), <String, Object?>{...existing, ...data});
}
}