set method

Transaction set(
  1. DocumentReference documentRef,
  2. Map<String, dynamic> data, [
  3. SetOptions? options
])

Writes to the document referred to by the provided DocumentReference. If the document does not exist yet, it will be created. If you pass options, the provided data can be merged into the existing document.

The DocumentReference parameter is a reference to the document to be created. Value must not be null.

The data paramater is object of the fields and values for the document. Value must not be null.

The optional options is an object to configure the set behavior. Pass {merge: true} to only replace the values specified in the data argument. Fields omitted will remain untouched. Value must not be null.

Returns non-null Transaction used for chaining method calls.

Implementation

Transaction set(DocumentReference documentRef, Map<String, dynamic> data,
    [firestore_interop.SetOptions? options]) {
  final jsObjectSet = (options != null)
      ? jsObject.set(documentRef.jsObject, jsify(data), options)
      : jsObject.set(documentRef.jsObject, jsify(data));
  return Transaction.getInstance(jsObjectSet);
}