Consider the following database in JSON format stored in firebase -
"root":
{
"survey":
{
"1":
{
"survey_question":"Who is a better player?",
"option1":"Ronaldo",
"option2":"Messi",
"time_posted":7854123265,
"visibility":1
},
"2":
{
"survey_question":"Who is a better singer?",
"option1":"Ed Sheeran",
"option2":"Chris Martin",
"time_posted":9865321245,
"visibility":1
}
}
}
I can write a Firebase cloud function which is triggered when a new survey is created.
But what should I do to update the visibility to 0
after 24 hours from time_posted
?
Edit: I checked out the solution for this question and followed the instructions-
- Wrote the function, in
index.js
file, which I want to be triggered and deployed it successfully. - Created a cron job at cron-job.org with the below address of the function-
https://us-central1-<PROJECT-ID>.cloudfunctions.net/<FUNCTION-NAME>?key=<PROJECT-KEY>
The cron job execution failed with the following error message-
Error: Forbidden
Your client does not have permission to get URL /<FUNCTION-NAME>?key=<PROJECT-KEY> from this server.