commit method

Future<void> commit()

Commits the batch of operations atomically.

Returns: A Future that completes when the commit is done.

Example:

await batch.commit();

Implementation

Future<void> commit() async {
  int idx = await __makeOperations();
  var transObj = {"name": __name, "start": 1 - __status, "end": 1};
  __status = -1;
  switch (__operations[idx]["method"]) {
    case "set":
      await __operations[idx]["docRef"].set(
          __operations[idx]["data"], __operations[idx]["options"], transObj);
      break;
    case "delete":
      await __operations[idx]["docRef"].delete(transObj);
      break;
    case "update":
      await __operations[idx]["docRef"]
          .update(__operations[idx]["data"], transObj);
      break;
    default:
  }
}