update method
Future<List<Blob> >
update({
- required QueryBuilder query(
- Collection collection
- Map<
String, dynamic> ? metadata, - Uint8List? bytes,
Implementation
Future<List<Blob>> update({
required QueryBuilder Function(Collection collection) query,
Map<String, dynamic>? metadata,
Uint8List? bytes,
}) async {
final rows = await query(_collection).get();
final updatedRows = <Document>[];
for (var row in rows) {
Document? updatedRow;
if (metadata != null && metadata.isNotEmpty) {
final data = {...row.data, ...metadata};
updatedRow = await _collection.updateById(row.id, data);
if (updatedRow != null) {
updatedRows.add(updatedRow);
}
} else {
updatedRow = row;
}
if (bytes != null && bytes.isNotEmpty) {
await _blobDiskDriver.updateChunks(row.id, bytes, _chunksSize);
}
}
return updatedRows
.map((row) => Blob(id: row.id, metadata: row, blobDiskDriver: _blobDiskDriver))
.toList();
}