I have already two images in the firestore database, I am trying to add a new image to this list? How can I add a new image to the existing image list?
Advertisement
Answer
To add another array to the postImg
, you can:
const db = firebase.firestore(); const colRef = db.collection("user@domain.com"); const docRef = colRef.doc("1fJBcGT8DlZdgbl01LeX"); docRef.update({ postImg: firebase.firestore.FieldValue.arrayUnion("thenewurl"); })
Also see the Firebase documentation on adding items to an array.