set<T> method

void set<T>(
  1. DocumentReference<T> documentRef,
  2. T data
)

Write to the document referred to by the provided DocumentReference. If the document does not exist yet, it will be created. If the document already exists, its contents will be overwritten with the newly provided data.

  • documentRef: A reference to the document to be set.
  • data The object to serialize as the document.

Implementation

void set<T>(DocumentReference<T> documentRef, T data) {
  if (_writeBatch == null) {
    throw Exception(readOnlyWriteErrorMsg);
  }
  _writeBatch.set<T>(documentRef, data);
}