I have Firestore document IDs stored in a firebase database node, and the security rules in firebase database need to only allow the deletion of and ID if the document it references in Firestore doesn't exist. Is there any way to do this? if not, is there a way to call a function from firebase database rules to check if the ID references an existing document in Firestore and have it return a value?
1
votes
2 Answers
1
votes
0
votes
You do not say where the database is being accessed from (web or app) but you could call a cloud function with the document id that you want to delete and then the cloud function could check whether the data the id references exists and if it does not, then delete the id from the firestore collection.
You could also add any additional logic you want in the cloud function.
https://firebase.google.com/docs/functions/get-started
In addition
https://firebase.google.com/docs/firestore/extend-with-functions
talks about how to extend the firestore capabilities using cloud functions.