0

I've searched the internet but haven't found anything that works for me. I describe what I need.

  • I have a function in firebase that is executed every time I add a new node to my Realtime Database

    exports.makeMagic = functions.database.ref("/users/{uid}")
    .onCreate((snap, context) => {
      const iterate = snap.val();
      if(iterate1.loops <= 5){
          // run 5 minutes later
          myFunction(iterate1,iterate2,iterate3); 
      }
    });
    
    

What I need is for myFunction to make a change to the database. But it must be strictly 5 minutes after the node is created. Not before and not after. I also don't want a cron job that is always running checking.

I have also read about using settimeout But this would block my "makeMagic" function, until the 5 minutes were up. And I think maximum can last 1 minute, I'm not sure about that.

Any help would be nice to keep trying

Thank you so much!

nacho1111
  • 73
  • 1
  • 8

1 Answers1

0

You can use Cloud Tasks, as explained in this article.

You will need to write another Cloud Function, of type HTTPS, which implements the desired business logic.

Renaud Tarnec
  • 79,263
  • 10
  • 95
  • 121