Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Trigger cloud function when a specific condition resulting from the comparison of document fields in firestore is true

In the observed document there are 2 fields that include timestamps, tsA and tsB.
tsA moves progressively closer to tsB until they eventually are the same – when this happens a cloud function shall be triggered, which performs a database operation in Firestore.
Is it possible to implement something like that – if so how?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

No, you cannot trigger a function when a specific condition is met in Firestore. You can use onUpdate() trigger and then compare the values in the function itself.

If this operation doesn’t need to be realtime then you can run a scheduled function (every few minutes/hours) that’ll query for all documents where tsA and tsB are same and then process them.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading