0

I have this database which has a table for users. which is updated every time a user is created in my fire-base.

table structure is like users -> {uid} -> (and some user parameters).

What i want to do is, for each user created i want to schedule its disabling after specific time. i tried using node-schedule but it is highly random, sometimes it works while sometimes not.

I have one cloud function which monitor an update on one field from sets of user field (user parameters). for example isRegistered field which is 1 at the time of user creation. and once it become zero function will release all the resource and also disable that specific user using its uid.

But i want one scheduler which will do this field updation for me after specific time lets say 5 hours meaning that user will have no longer access to my database after 5 hours. How can i approach this?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Possible duplicate of [Cloud Functions for Firebase trigger on time?](https://stackoverflow.com/questions/42790735/cloud-functions-for-firebase-trigger-on-time) – Doug Stevenson Nov 22 '17 at 18:52
  • I dont want a cron job which will execute at predefined time rather it should be dynamic , meaning after a specific time after user creation. – Akshay Hiwale Nov 22 '17 at 19:18
  • Either way, you'll need to bring your own scheduling mechanism. Use it to ping your function periodically and have to check to see what work needs to be done. – Doug Stevenson Nov 22 '17 at 19:33
  • pinging periodically will lead to more overhead when there are more number of users. what kind of scheduling mechanism should i implement? – Akshay Hiwale Nov 22 '17 at 20:13
  • Periodic polling is your only option currently. You can use the advice in the question that I marked as a dup. – Doug Stevenson Nov 22 '17 at 20:21
  • ok thanks, will look after it. But this isn't efficient solution. let me know if you come up with something else. – Akshay Hiwale Nov 22 '17 at 23:00

0 Answers0