update method
Implementation
@override
Future<T> update(String id, T Function(T) updater) async {
try {
final existingItem = await get(id);
final updatedItem = updater(existingItem);
final document = _toFirestore(updatedItem, id);
final parent =
collectionParentPath.isEmpty
? documentsPath
: '$documentsPath/$collectionParentPath';
final documentPath = '$parent/$collectionId/$id';
document.name = documentPath;
//only update whats changed.......
final updatedDocument = await _firestore.projects.databases.documents
.patch(document, documentPath, currentDocument_exists: true);
return _fromFirestore(updatedDocument);
} catch (e) {
if (e is DetailedApiRequestError) {
if (e.status == 404) {
throw RepositoryException(
message: 'Item with id $id not found',
code: RepositoryErrorCode.notFound,
);
}
}
rethrow;
}
}