【发布时间】:2019-02-22 16:40:32
【问题描述】:
我有一个带有存储触发器的云函数,我知道我需要返回 promise 以正确结束我所做的函数,但我仍然在控制台中收到警告说“函数返回未定义、预期的 Promise 或值”。
exports.elementChange = functions.storage.object().onFinalize((object) => {
var element = {
name: object.name,
time: object.updated
}
db.collection('elements').doc(object.name).set(element)
.then(()=> {
return db.collection('elements').get()
})
.then((snapshot) => {
return db.collection('stats').doc('elementCount').update({elementCount : snapshot.size});
})
.catch(err => console.log('Error when finalise element: '+ err))
})
【问题讨论】:
标签: google-cloud-firestore google-cloud-functions