UNPKG

voluptasmollitia

Version:
30 lines (17 loc) 1.34 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@firebase/firestore](./firestore.md) &gt; [lite](./firestore_lite.md) &gt; [addDoc](./firestore_lite.adddoc.md) ## addDoc() function Add a new document to specified `CollectionReference` with the given data, assigning it a document ID automatically. The result of this write will only be reflected in document reads that occur after the returned Promise resolves. If the client is offline, the write fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. <b>Signature:</b> ```typescript export declare function addDoc<T>(reference: CollectionReference<T>, data: T): Promise<DocumentReference<T>>; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | | reference | [CollectionReference](./firestore_lite.collectionreference.md)<!-- -->&lt;T&gt; | A reference to the collection to add this document to. | | data | T | An Object containing the data for the new document. | <b>Returns:</b> Promise&lt;[DocumentReference](./firestore_lite.documentreference.md)<!-- -->&lt;T&gt;&gt; A Promise resolved with a `DocumentReference` pointing to the newly created document after it has been written to the backend.