Skip to content

react-query-firebase / getDocData

Function: getDocData() ​

ts
function getDocData<AppModelType>(options): Promise<AppModelType & object | null>;

Defined in: src/web/firestore/utils/getDocData.ts:20

Asynchronously retrieves document data from a specified database reference. Utilizes the helper function getDocSnap to fetch the document snapshot and checks if the document exists before returning its data.

Type Parameters ​

AppModelType ​

AppModelType extends AppModel = AppModel

Parameters ​

options ​

The options for fetching document data.

db ​

Firestore

path? ​

string

pathSegments? ​

string[]

reference? ​

| CollectionReference<AppModelType, AppModelType> | DocumentReference<AppModelType, AppModelType>

Returns ​

Promise<AppModelType & object | null>

Returns a promise that resolves to the document data if it exists, or null if the document does not exist.

Released under the MIT License.