0
votes

I'm using firestore with AngularFire 2 and one of my fields a reference to a different document.

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:

DocumentReference.update() called with invalid data. Unsupported field value: a custom AngularFirestoreDocument object`

public updateConfig(newConfig: ConfigId) {
    const preset: AngularFirestoreDocument<Config> = this.db.doc<Config>('/reference/path');
    this.businessDoc.update({'config': preset})
}

Thanks!

1

1 Answers

1
votes

This was simple, but it took a deep dive into firebase. Just add .ref to your AngularFirestoreDocument

public updateConfig(newConfig: ConfigId) {
    const preset: AngularFirestoreDocument<Config> = this.db.doc<Config>('/presets/' + newConfig.id);
    this.businessDoc.update({'config': preset.ref})
}