updateOneFromMap method
Same as updateOne but in Map format. Schema: { updateOne : { "filter":
Implementation
void updateOneFromMap(Map<String, Object> docMap, {int? index}) {
var filterMap = docMap[bulkFilter];
if (filterMap is! Map<String, Object>) {
throw MongoDartError('The "$bulkFilter" key of the '
'"$bulkUpdateOne" element '
'${index == null ? '' : 'at index $index '}must '
'contain a Map');
}
if (docMap[bulkUpdate] is! Map<String, Object> &&
docMap[bulkUpdate] is! List<Map<String, dynamic>>) {
throw MongoDartError('The "$bulkUpdate" key of the '
'"$bulkUpdateOne" element '
'${index == null ? '' : 'at index $index '}must '
'contain a Map or a pipeline (List<Map>)');
}
if (docMap[bulkUpsert] != null && docMap[bulkUpsert] is! bool) {
throw MongoDartError('The "$bulkUpsert" key of the '
'"$bulkUpdateOne" element '
'${index == null ? '' : 'at index $index '}must '
'contain a bool');
}
if (docMap[bulkCollation] != null &&
docMap[bulkCollation] is! CollationOptions &&
docMap[bulkCollation] is! Map<String, dynamic>) {
throw MongoDartError('The "$bulkCollation" key of the '
'"$bulkUpdateOne" element '
'${index == null ? '' : 'at index $index '}must '
'contain a CollationOptions element or a Map representation '
'of a collation');
}
if (docMap[bulkArrayFilters] != null &&
docMap[bulkArrayFilters] is! List<Map<String, dynamic>>) {
throw MongoDartError('The "$bulkArrayFilters" key of the '
'"$bulkUpdateOne" element '
'${index == null ? '' : 'at index $index '}must '
'contain a List<Map<String, dynamic>> Object');
}
if (docMap[bulkHint] != null && docMap[bulkHint] is! String) {
throw MongoDartError('The "$bulkHint" key of the '
'"$bulkUpdateOne" element '
'${index == null ? '' : 'at index $index '}must '
'contain a String');
}
if (docMap[bulkHintDocument] != null &&
docMap[bulkHintDocument] is! Map<String, Object>) {
throw MongoDartError('The "$bulkHintDocument" key of the '
'"$bulkUpdateOne" element '
'${index == null ? '' : 'at index $index '}must '
'contain a Map');
}
updateOne(UpdateOneStatement(filterMap, docMap[bulkUpdate] as Object,
upsert: docMap[bulkUpsert] as bool?,
collation: docMap[bulkCollation] is Map<String, dynamic>
? CollationOptions.fromMap(
docMap[bulkCollation] as Map<String, Object>)
: docMap[bulkCollation] as CollationOptions?,
arrayFilters: docMap[bulkArrayFilters] as List?,
hint: docMap[bulkHint] as String?,
hintDocument: docMap[bulkHintDocument] as Map<String, Object>?));
}