replaceOne method
Implementation
Future<FormResultFree?> replaceOne(
String id,
Map<String, Object?> data,
) async {
var oid = ObjectId.tryParse(id);
if (oid == null || !await existId(id)) {
return null;
}
FormResultFree validationResult = validate(data);
if (validationResult.success) {
var newData = validationResult.formValues();
newData['_id'] = oid;
var result = await collection.replaceOne(
where.id(oid),
newData,
);
var newUpdate = await getById(id);
if (result.isSuccess && newUpdate != null) {
validationResult.updateValues(newUpdate);
}
}
return validationResult;
}