-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Description
Version info
Angular: 7.2.0
Firebase: 5.8.2
AngularFire: 5.1.1
I am trying to update an array "likedPosts" for a User-Document:
User Model:
export interface User {
uid: string;
email: string;
photoURL?: string;
displayName?: string;
likedPosts?: string[];
createdPosts?: string[];
}
Update array:
const userRef: AngularFirestoreDocument<User> = this.afs.doc(
`users/${uid}`
);
userRef.update({
likedPosts: firestore.FieldValue.arrayUnion("post23")
});
I am getting the following error:
[ts] Type 'FieldValue' is missing the following properties from type 'string[]': length, pop, push, concat, and 26 more. [2740]
User.ts(6, 3): The expected type comes from property 'likedPosts' which is declared here on type 'Partial'
This is the example code from firebase.com:
var washingtonRef = db.collection("cities").doc("DC");
// Atomically add a new region to the "regions" array field.
washingtonRef.update({
regions: firebase.firestore.FieldValue.arrayUnion("greater_virginia")
});
// Atomically remove a region from the "regions" array field.
washingtonRef.update({
regions: firebase.firestore.FieldValue.arrayRemove("east_coast")
});
test.firestore.js
Thank you for your help!
avazquez0191, vhanded, LeonardoRick, ann-k, pavelgorbach and 4 more
Metadata
Metadata
Assignees
Labels
No labels