【发布时间】:2021-02-23 18:39:08
【问题描述】:
我正在使用 Angular 和 google cloud firestore 来加载数据。
我也有一个模型类,我们就叫它IMyModel
export interface IMyModel{
data: any;
id: string;
}
其中id 是firestore 上文档的id。我可以很容易地通过
var docs = this.firestore.collection('myCollection').valueChanges({ idField: 'id' }) as Observable<IMyModel[]>;这很好用。
但是现在,我也想要这个功能与文档参考。假设我改变了模型
export interface IMyModel{
data: any;
documentReference: DocumentReference;
}
我现在如何插入documentReference 字段?我已经试过了
var docs = this.firestore.collection('myCollection').valueChanges({ ref: 'documentReference', }) as Observable<IMyModel[]>;
但这不会插入字段。
【问题讨论】:
标签: javascript angular firebase google-cloud-firestore angularfire2