CollectionReference
物件可用於新增文件、取得文件參考和查詢文件(使用query() )。
簽名:
export declare class CollectionReference<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData> extends Query<AppModelType, DbModelType>
擴充:查詢<應用程式模型類型,Db模型類型>
特性
財產 | 修飾符 | 類型 | 描述 |
---|---|---|---|
ID | 細繩 | 集合的識別符。 | |
家長 | 文件參考<文檔數據,文檔數據> |無效的 | 如果這是子集合,則對包含DocumentReference 參考。如果這不是子集合,則引用為空。 | |
小路 | 細繩 | 表示引用集合的路徑(相對於資料庫的根)的字串。 | |
類型 | (未聲明) | 此 Firestore 引用的類型。 |
方法
方法 | 修飾符 | 描述 |
---|---|---|
與轉換器(轉換器) | 將自訂資料轉換器套用到此CollectionReference ,讓您可以將自己的自訂模型物件與 Firestore 結合使用。當您使用傳回的CollectionReference 實例呼叫addDoc()時,提供的轉換器將在NewDbModelType 類型的 Firestore 資料和您的自訂類型NewAppModelType 之間進行轉換。 | |
與轉換器(轉換器) | 移除電流轉換器。 |
集合參考.id
集合的識別符。
簽名:
get id(): string;
CollectionReference.parent
如果這是子集合,則對包含DocumentReference
參考。如果這不是子集合,則引用為空。
簽名:
get parent(): DocumentReference<DocumentData, DocumentData> | null;
CollectionReference.path
表示引用集合的路徑(相對於資料庫的根)的字串。
簽名:
get path(): string;
CollectionReference.type
此 Firestore 引用的類型。
簽名:
readonly type = "collection";
CollectionReference.withConverter()
將自訂資料轉換器套用至此CollectionReference
,讓您可以將自己的自訂模型物件與 Firestore 結合使用。當您使用傳回的CollectionReference
實例呼叫addDoc()時,提供的轉換器將在NewDbModelType
類型的 Firestore 資料和您的自訂類型NewAppModelType
之間進行轉換。
簽名:
withConverter<NewAppModelType, NewDbModelType extends DocumentData = DocumentData>(converter: FirestoreDataConverter<NewAppModelType, NewDbModelType>): CollectionReference<NewAppModelType, NewDbModelType>;
參數
範圍 | 類型 | 描述 |
---|---|---|
轉換器 | Firestore資料轉換器<新應用程式模型類型、新資料庫模型類型> | 將物件與 Firestore 相互轉換。 |
返回:
收藏參考<新應用程式模型類型、新資料庫模型類型>
使用提供的轉換器的CollectionReference
。
CollectionReference.withConverter()
移除電流轉換器。
簽名:
withConverter(converter: null): CollectionReference<DocumentData, DocumentData>;
參數
範圍 | 類型 | 描述 |
---|---|---|
轉換器 | 無效的 | null 刪除目前轉換器。 |
返回:
不使用轉換器的CollectionReference<DocumentData, DocumentData>
。