我尝试从答案https://stackoverflow.com/a/51909724/11833020中遵循本指南,要在https://cron-job.org/上使用firebase实时数据库执行cron作业,但每次都会失败。
我遇到类似“位置:https://accounts.google.com/ServiceLogin?service=ah&passive=true&continue=https://appengine.google.com/_ah/conflogin%3Fcontinue%3Dhttp ...”的错误
具有实时数据库的cron作业还需要大火计划还是什么?
编辑过:根据@DougStevenson的回答,我去仔细检查了所有内容,并在index.js中出现了一个小错误,我对其进行了修复,并且所有内容都可以从云函数日志中很好地执行,但是我没有从数据库中删除任何内容刚刚更改了上述链接中的代码以适合我的数据库结构,例如:
exports.removeOldMessages = functions.https.onRequest((req, res) => {
const timeNow = Date.now();
const messagesRef = admin.database().ref('/messages/{user_id}/{passed_id}');
messagesRef.once('value', (snapshot) => {
snapshot.forEach((child) => {
if ((Number(child.val()['time']) + Number(child.val()['duration'])) <= timeNow) {
child.ref.set(null);
}
});
});
return res.status(200).end();
});
从图像中可以看到,这就是我的数据库的结构,不是我的代码在index.js中必须是什么样子?
https://i.stack.imgur.com/l2Qgb.jpg
出于记录,我对javascript的编程知识了解为零,我只是阅读firebase文档,我只是一个初学者android开发人员,欢迎任何帮助或建议。谢谢