Google cloud firestore 谷歌云功能-存储触发器抱怨返回未定义
我有一个带有存储触发器的云函数,我知道我需要返回承诺以正确结束我所做的函数,但我仍然在控制台中收到警告:“函数返回了未定义的、预期的承诺或值”Google cloud firestore 谷歌云功能-存储触发器抱怨返回未定义,google-cloud-firestore,google-cloud-functions,Google Cloud Firestore,Google Cloud Functions,我有一个带有存储触发器的云函数,我知道我需要返回承诺以正确结束我所做的函数,但我仍然在控制台中收到警告:“函数返回了未定义的、预期的承诺或值” 你实际上没有从你的函数中返回承诺。将关键字return放在db.collection(…)之前 exports.elementChange = functions.storage.object().onFinalize((object) => { var element = { name: object.name,
你实际上没有从你的函数中返回承诺。将关键字
return
放在db.collection(…)
之前
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))
})