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>
。