Best way to execute a cloud function after a set time

I need a cloud function to be called, then writes something to the database and then call another cloud function after, say 30 seconds, and then make some more updates to the databse.

I know firebase discourages setInterval this because it hangs up the server. though I’m not clear if moralis charges by time?

I could also execute a job every second that would get a query for every record that matches a certain timestamp + 30 seconds…

but this sounds wasteful too.

Or is it? What’s the best way?

I don’t want to depend on the client to have to trigger the cloud functions…

I don’t know exactly what is the best way, you are not going to be charged on execution time for cloud functions
I don’t think that you can set a job to run ever second, maybe you can start a job and add some kind of sleep (also make sure that you have some kind of way to stop that job like checking for a marker in db)

1 Like

Is it possible to start a job programmtically?

I don’t know of a way to start a job programmatically

1 Like