[英]Firestore: How to update a document's field that is a document reference?
I'm using firestore with AngularFire 2 and one of my fields a reference to a different document. 我将Firestore与AngularFire 2配合使用,并且其中一个字段引用了另一个文档。
I'm able to use this field in my angular app, but: How do I update this field? 我可以在我的角度应用程序中使用此字段,但是:如何更新此字段?
I'm trying creating a new AngularFirestoreDocument
pointing to the correct reference but I'm getting: 我正在尝试创建一个指向正确引用的新
AngularFirestoreDocument
,但我得到了:
DocumentReference.update() called with invalid data.
使用无效数据调用的DocumentReference.update()。 Unsupported field value: a custom AngularFirestoreDocument object`
不支持的字段值:自定义AngularFirestoreDocument对象
public updateConfig(newConfig: ConfigId) {
const preset: AngularFirestoreDocument<Config> = this.db.doc<Config>('/reference/path');
this.businessDoc.update({'config': preset})
}
Thanks! 谢谢!
This was simple, but it took a deep dive into firebase. 这很简单,但是深入研究了火力场。 Just add
.ref
to your AngularFirestoreDocument
只需将
.ref
添加到您的AngularFirestoreDocument
public updateConfig(newConfig: ConfigId) {
const preset: AngularFirestoreDocument<Config> = this.db.doc<Config>('/presets/' + newConfig.id);
this.businessDoc.update({'config': preset.ref})
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.