【发布时间】:2021-08-02 04:59:05
【问题描述】:
我的收藏有大约。 20.000 个文档,当我尝试通过以下代码更新每个文档时;我收到此错误:Error: 9 FAILED_PRECONDITION: The 'read_time' cannot be more than 270 seconds in the past. The requested value was '2021-05-11T19:09:49.064209Z', but the minimum allowed value was '2021-05-11T19:10:23.865748Z'. 我尝试通过使用批处理来解决此问题,但没有成功。有什么推荐吗?
exports.scheduledFunctionFilms = functions.runWith(runtimeOpts).region('europe-west3').pubsub.schedule('0 05 * * 0').timeZone('Europe/Istanbul').onRun((context) => {
db.collection('Films').get().then(querySnapshot => {
if (querySnapshot.empty) {
console.log("null film")
return null;
} else {
const promises = []
console.log("started film")
querySnapshot.forEach(doc => {
promises.push(doc.ref.update({sectionPoint:0}));
});
console.log("finished film")
return Promise.all(promises);
}
}).catch(error => {
console.log('uncaught error film: ', error);
});
【问题讨论】:
-
您能否在批量更新文档时更新您的代码并包含逻辑?也许这篇文章可以提供帮助:stackoverflow.com/questions/52165352/…
标签: firebase google-cloud-functions