【发布时间】:2018-08-26 02:09:28
【问题描述】:
我正在从谷歌云函数中的 firebase 文档中复制此代码:
var cityRef = db.collection('cities').doc('SF');
var transaction = db.runTransaction(t => {
return t.get(cityRef)
.then(doc => {
// Add one person to the city population
var newPopulation = doc.data().population + 1;
t.update(cityRef, { population: newPopulation });
});
}).then(result => {
console.log('Transaction success!');
}).catch(err => {
console.log('Transaction failure:', err);
});
但我得到:property 'data' does not exist on type 'QuerySnapshot' 它应该是一个文档快照。
【问题讨论】:
标签: node.js firebase google-cloud-firestore google-cloud-functions