javascript - How to delete data from a Firebase database on a schedule -


i have created simple chatroom-like apache cordova (html) application allows users add own messages custom usernames in chatroom.

the messages add after while , have go actual database delete them every day avoid clutter.

is there way can create rule or javascript function clear data @ time every day? instance @ 9 database clear content previous day , night , start day fresh.

thanks help.

from looks of there 2 current similar solutions: creating scheduled task in javascript || later.js execute function on schedule?

i unfamiliar later.js can't there.

using gdoron's code, believe code should similar this:

function foo(){     var day =new date().getday();     var hours =new date().gethours();      if (day === 0 && hours >12 && hours < 13)  // day 0 index base                                                // sunday between 12:00 , 13:00  //what want goes here var fredref = new firebase('yourdirectoryurl') fredref.remove();  }  setinterval(foo, 3600000); // 1 hour check. 

notes:

  • remember include

    <script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script> 

  • also, keep in mind clear everything.

  • Comments