Query class

Query是指您可以閱讀或聆聽的查詢。您也可以透過新增篩選器和排序來建構精煉的Query物件。

簽名:

export declare class Query<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData> 

建構函數

建構函數修飾符描述
(構造函數)()建構Query類別的新實例

特性

財產修飾符類型描述
轉換器Firestore資料轉換器<AppModelType,DbModelType> |無效的如果提供,則為與此執行個體關聯的FirestoreDataConverter
火庫火庫Firestore 資料庫的Firestore執行個體(用於執行交易等)。
類型'查詢' | '收藏'此 Firestore 引用的類型。

方法

方法修飾符描述
與轉換器(轉換器)移除電流轉換器。
與轉換器(轉換器)對此查詢套用自訂資料轉換器,讓您可以將自己的自訂模型物件與 Firestore 結合使用。當您使用傳回的查詢呼叫getDocs()時,提供的轉換器將在NewDbModelType類型的 Firestore 資料和您的自訂類型NewAppModelType之間進行轉換。

查詢。(建構函數)

建構Query類別的新實例

簽名:

protected constructor();

查詢轉換器

如果提供,則為與此執行個體關聯的FirestoreDataConverter

簽名:

readonly converter: FirestoreDataConverter<AppModelType, DbModelType> | null;

查詢.firestore

Firestore 資料庫的Firestore執行個體(用於執行交易等)。

簽名:

readonly firestore: Firestore;

查詢類型

此 Firestore 引用的類型。

簽名:

readonly type: 'query' | 'collection';

Query.withConverter()

移除電流轉換器。

簽名:

withConverter(converter: null): Query<DocumentData, DocumentData>;

參數

範圍類型描述
轉換器無效的null刪除目前轉換器。

返回:

詢問<文檔數據,文檔數據>

不使用轉換器的Query<DocumentData, DocumentData>

Query.withConverter()

對此查詢套用自訂資料轉換器,讓您可以將自己的自訂模型物件與 Firestore 結合使用。當您使用傳回的查詢呼叫getDocs()時,提供的轉換器將在NewDbModelType類型的 Firestore 資料和您的自訂類型NewAppModelType之間進行轉換

簽名:

withConverter<NewAppModelType, NewDbModelType extends DocumentData = DocumentData>(converter: FirestoreDataConverter<NewAppModelType, NewDbModelType>): Query<NewAppModelType, NewDbModelType>;

參數

範圍類型描述
轉換器Firestore資料轉換器<新應用程式模型類型、新資料庫模型類型>將物件與 Firestore 相互轉換。

返回:

詢問<新應用程式模型類型、新資料庫模型類型>

使用提供的轉換器的Query