QueryDocumentSnapshot class

QueryDocumentSnapshot包含作為查詢的一部分從 Firestore 資料庫中的文件讀取的資料。此文件保證存在,並且可以使用.data().get(<field>)提取其資料以取得特定欄位。

QueryDocumentSnapshot提供與DocumentSnapshot相同的 API 介面。由於查詢結果僅包含現有文檔, exists屬性將始終為 true,且data()永遠不會返回「未定義」。

簽名:

export declare class QueryDocumentSnapshot<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData> extends DocumentSnapshot<AppModelType, DbModelType> 

擴充: DocumentSnapshot <應用程式模型類型,Db模型類型>

方法

方法修飾符描述
數據(選項)Object形式檢索文件中的所有欄位。預設情況下,尚未設定為最終值的serverTimestamp()值將傳回為null 。您可以透過傳遞選項物件來覆寫它。

QueryDocumentSnapshot.data()

Object檢索文件中的所有字段

預設情況下,尚未設定為最終值的serverTimestamp()值將傳回null 。您可以透過傳遞選項物件來覆寫它。

簽名:

/** @override */
data(options?: SnapshotOptions): AppModelType;

參數

範圍類型描述
選項快照選項選項對象,用於配置如何從快照檢索資料(例如,尚未設定為其最終值的伺服器時間戳記的所需行為)。

返回:

應用程式模型類型

包含文件中所有欄位的Object