Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

setDoc

Writes to the document referred to by this DocumentReference. If the document does not yet exist, it will be created.

Note that the returned Promise does not resolve until the data is successfully written to the remote Firestore backend and, similarly, is not rejected until the remote Firestore backend reports an error saving the given data. So if the client cannot reach the backend (for example, due to being offline) then the returned Promise will not resolve for a potentially-long time (for example, until the client has gone back online). That being said, the given data will be immediately saved to the local cache and will be incorporated into future "get" operations as if it had been successfully written to the remote Firestore server, a feature of Firestore called "latency compensation". The data will eventually be written to the remote Firestore backend once a connection can be established. Therefore, it is usually undesirable to await the Promise returned from this function because the indefinite amount of time before which the promise resolves or rejects can block application logic unnecessarily.

function setDoc<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>, data: WithFieldValue<AppModelType>): Promise<void>;
function setDoc<AppModelType, DbModelType extends DocumentData>(
reference: DocumentReference<AppModelType, DbModelType>,
data: PartialWithFieldValue<AppModelType>,
options: SetOptions,
): Promise<void>;
§
setDoc<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>, data: WithFieldValue<AppModelType>): Promise<void>
[src]

Writes to the document referred to by this DocumentReference. If the document does not yet exist, it will be created.

Note that the returned Promise does not resolve until the data is successfully written to the remote Firestore backend and, similarly, is not rejected until the remote Firestore backend reports an error saving the given data. So if the client cannot reach the backend (for example, due to being offline) then the returned Promise will not resolve for a potentially-long time (for example, until the client has gone back online). That being said, the given data will be immediately saved to the local cache and will be incorporated into future "get" operations as if it had been successfully written to the remote Firestore server, a feature of Firestore called "latency compensation". The data will eventually be written to the remote Firestore backend once a connection can be established. Therefore, it is usually undesirable to await the Promise returned from this function because the indefinite amount of time before which the promise resolves or rejects can block application logic unnecessarily.

§Type Parameters

§
AppModelType
[src]
§
DbModelType extends DocumentData
[src]

§Parameters

§
reference: DocumentReference<AppModelType, DbModelType>
[src]
  • A reference to the document to write.
§
data: WithFieldValue<AppModelType>
[src]
  • A map of the fields and values for the document.

§Return Type

§
Promise<void>
[src]

A Promise that resolves once the data has been successfully written to the backend or rejects once the backend reports an error writing the data.

§
setDoc<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>, data: PartialWithFieldValue<AppModelType>, options: SetOptions): Promise<void>
[src]

Writes to the document referred to by the specified DocumentReference. If the document does not yet exist, it will be created. If you provide merge or mergeFields, the provided data can be merged into an existing document.

Note that the returned Promise does not resolve until the data is successfully written to the remote Firestore backend and, similarly, is not rejected until the remote Firestore backend reports an error saving the given data. So if the client cannot reach the backend (for example, due to being offline) then the returned Promise will not resolve for a potentially-long time (for example, until the client has gone back online). That being said, the given data will be immediately saved to the local cache and will be incorporated into future "get" operations as if it had been successfully written to the remote Firestore server, a feature of Firestore called "latency compensation". The data will eventually be written to the remote Firestore backend once a connection can be established. Therefore, it is usually undesirable to await the Promise returned from this function because the indefinite amount of time before which the promise resolves or rejects can block application logic unnecessarily.

§Type Parameters

§
AppModelType
[src]
§
DbModelType extends DocumentData
[src]

§Parameters

§
reference: DocumentReference<AppModelType, DbModelType>
[src]
  • A reference to the document to write.
§
data: PartialWithFieldValue<AppModelType>
[src]
  • A map of the fields and values for the document.
§
  • An object to configure the set behavior.

§Return Type

§
Promise<void>
[src]

A Promise that resolves once the data has been successfully written to the backend or rejects once the backend reports an error writing the data.