update method

WriteBatch update(
  1. DocumentReference<Object?> documentRef,
  2. Map<Object, Object?> data
)

Updates the fields in data of the document referred to by documentRef. Each key is a field path: a String (dots separate nested fields) or a FieldPath. The batch fails if the document does not exist.

Implementation

WriteBatch update(
  DocumentReference<Object?> documentRef,
  Map<Object, Object?> data,
) {
  final UserDataParsedUpdateData parsed = _firestore.dataConverter
      .parseUpdateMap(
        data,
        methodName: 'WriteBatch.update',
        targetDoc: documentRef.key,
      );
  _firestore.validateReference(documentRef);
  _verifyNotCommitted();
  _mutations.add(
    parsed.toMutation(documentRef.key, Precondition(exists: true)),
  );
  return this;
}