set<T> method

void set<T>(
  1. DocumentReference<T> docRef,
  2. T data,
  3. [SetOptions? options]
)

Queues a set operation for the given document.

Parameters:

  • docRef: The document reference.
  • data: The data to set.
  • options: Optional set options (e.g., merge).

Example:

batch.set(docRef, {'field': 'value'}, SetOptions(merge: true));

Implementation

void set<T>(DocumentReference<T> docRef, T data, [SetOptions? options]) {
  options ??= SetOptions(merge: false);

  __operations.add(
      {"method": "set", "docRef": docRef, "data": data, "options": options});
}