【发布时间】:2020-04-01 22:21:27
【问题描述】:
我想将每个文档的 id 作为该文档的一个字段,以便我可以将其存储在文档中。这是我创建的云函数:
exports.assignPID = functions.database
.ref('/players/{playerId}')
.onCreate((snapshot,context)=>{
const playerId = context.params.playerId;
console.log("new player "+playerId);
// const data = snapshot.val();
return snapshot.ref.update({'pid': playerId})
})
这部署没有任何错误,但每当我将新文档添加到“玩家”集合时,文档中没有任何变化
【问题讨论】:
标签: javascript firebase google-cloud-firestore google-cloud-functions