In my Cloud Firestore setup (iOS/Swift app), I have a Post collection with a Likes subcollection. The Likes subcollection has a document that contains the information of the user that liked that post, with the documentID being the userID of the liker.
When the user updates their post, I want to clear the Likes subcollection (in my app, the user just updates a post instead of creating a new one).
I have read that deleting every document in a subcollection is not advised, so I am wondering how I can accomplish this. A popular user could have thousands and thousands of likes, so deleting them all could be costly.
It's my understanding that I can accomplish this somehow using Cloud Functions? I tried reading up on Cloud Functions and I'm getting pretty lost. Is there a way I can trigger a Cloud Function to delete all the documents in the Likes subcollection for that user upon updating their post?