insert method

Future<FormResultFree> insert(
  1. Map<String, Object?> data
)

Implementation

Future<FormResultFree> insert(Map<String, Object?> data) async {
  var validationResult = validate(data);
  if (validationResult.success) {
    var result = await collection.insertOne(validationResult.formValues());

    if (!result.isFailure && result.document != null) {
      validationResult.updateValues(result.document!);
    } else {
      validationResult.updateFromMongoResponse(result.serverResponses);
    }
  }
  return validationResult;
}