我想刪除兩個小時以前的任何數據。我知道這個問題已經在這裏找到答案Delete firebase data older than 2 hoursFirebase Cloud功能在特定時間後自動刪除數據
答案是:
var ref = new Firebase('https://yours.firebaseio.com/path/to/items/');
var now = Date.now();
var cutoff = now - 2 * 60 * 60 * 1000;
var old = ref.orderByChild('timestamp').endAt(cutoff).limitToLast(1);
var listener = old.on('child_added', function(snapshot) {
snapshot.ref().remove();
});
但有人可以在將其轉換成它的NodeJS我可以部署到雲火力功能功能幫助。
博客文章專門解決此問題:https://firebase.googleblog.com/2017/03/how-to-schedule-cron-jobs-with-cloud.html。另請參閱此[Cloud Functions示例](https://github.com/firebase/functions-samples/tree/master/delete-unused-accounts-cron) –
請參閱http://stackoverflow.com/questions/42790735/cloud -functions-for-firebase-trigger-on-time –