Issue
I have been trying to learn using Firestore and could not find the documentation helpful at all in the case AngularFire since using FieldValue just throws an error as "FieldValue does not exist".
const userRef = this.firestore.collection('users').doc(email);
userRef.update({
lessonsWatched: this.firestore.FieldValue.arrayUnion(newLessonObject)
})
What am I missing here?
Solution
import { arrayUnion } from '@angular/fire/firestore';
this.firestore.doc(...).update({ field: arrayUnion(...) });
Similar should work for other FieldValue functions, such as increment
.
See:
- https://github.com/angular/angularfire/issues/2036#issuecomment-1337755616
- https://stackoverflow.com/a/74691835
Answered By - Doug Stevenson
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.