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

addDoc

Add a new document to specified CollectionReference with the given data, assigning it a document ID automatically.

Note that the returned Promise does not resolve until the document is successfully created to the remote Firestore backend and, similarly, is not rejected until the remote Firestore backend reports an error creating the given document. 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 document will be immediately created in the local cache and will be incorporated into future "get" operations as if it had been successfully created in the remote Firestore server, a feature of Firestore called "latency compensation". The document will eventually be created in 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 addDoc<AppModelType, DbModelType extends DocumentData>(reference: CollectionReference<AppModelType, DbModelType>, data: WithFieldValue<AppModelType>): Promise<DocumentReference<AppModelType, DbModelType>>;
§
addDoc<AppModelType, DbModelType extends DocumentData>(reference: CollectionReference<AppModelType, DbModelType>, data: WithFieldValue<AppModelType>): Promise<DocumentReference<AppModelType, DbModelType>>
[src]

§Type Parameters

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

§Parameters

§
reference: CollectionReference<AppModelType, DbModelType>
[src]
  • A reference to the collection to add this document to.
§
data: WithFieldValue<AppModelType>
[src]
  • An Object containing the data for the new document.

§Return Type

§
Promise<DocumentReference<AppModelType, DbModelType>>
[src]

A Promise that resolves once the docoument has been successfully created in the backend or rejects once the backend reports an error creating the document.