set method

JSPromise<WriteResult> set(
  1. DocumentReference documentRef,
  2. JSObject data, [
  3. SetOptions options
])

Write to the document referred to by the provided DocumentReference{@link DocumentReference}. If the document does not exist yet, it will be created. If you pass SetOptions{@link SetOptions}., the provided data can be merged into the existing document.

@param documentRef A reference to the document to be set. @param data The object to serialize as the document. @param options An object to configure the set behavior. @param options.merge - If true, set() merges the values specified in its data argument. Fields omitted from this set() call remain untouched. If your input sets any field to an empty map, all nested fields are overwritten. @param options.mergeFields - If provided, set() only replaces the specified field paths. Any field path that is not specified is ignored and remains untouched. If your input sets any field to an empty map, all nested fields are overwritten. @throws Error If the provided input is not a valid Firestore document. @returns A promise that resolves with the result of the write. If the write fails, the promise is rejected with a BulkWriterError{@link BulkWriterError}.

Implementation

external JSPromise<WriteResult> set(
  DocumentReference documentRef,
  JSObject data, [
  SetOptions options,
]);