How do I delete a photo in Firestore from a nested photos collection?
I have a nested collection of photos in my user document.
The following code works! But, I am wondering if there is an easier way to do it.
const userDoc = await firestore
.collection('users')
.doc(user.uid)
.get();
const userDocPhoto = userDoc.data().photos.find(p => p.url === url);
firestore
.collection('users')
.doc(user.uid)
.update({
photos: firebase.firestore.FieldValue.arrayRemove(userDocPhoto)
});
I like the real-time nature of Firestore and its similarity to Mongo but if I wish that the API was easier :(