我要做的是在预定时间使用云功能和云任务更改firestore中的数据。但是云任务没有按时运行。它在添加任务后立即执行。
我的代码是这样的。
index.js
exports.addTasks = functions.https.onCall((data, context) => {
const client = new tasks.CloudTasksClient()
const projectId = ...
const queue = ...
const location = ...
const parent = client.queuePath(projectId, location, queue)
const url = ... .cloudfunctions.net/doSomething?docId=' + docId
const task = {
httpRequest: {
httpMethod: 'POST',
url: url,
scheduleTime: {
seconds: 3 * 60 + Date.now() / 1000,
},
}
}
const request = {
parent: parent,
task: task,
}
client.createTask(request)
})
exports.doSomething = functions.https.onRequest((req, res) => {
var db = admin.firestore()
var docId = req.query.docId
var docRef = db.collection('people').doc(docId)
docRef.update({
changeHere: true,
})
})
我想在执行doSomething
后 3 分钟运行函数addTasks
。我有什么问题?