1

这是我非常基本的云功能:错误:没有实体更新:应用 - 云计算的FireStore功能

const functions = require('firebase-functions'); 
const admin = require('firebase-admin'); 
admin.initializeApp(functions.config().firebase); 
const db = admin.firestore() 

exports.createdNewAccount = functions.auth.user().onCreate(event => { 
    return db.collection('users').doc(event.data.uid).update({ 
     "creationDate" : Date.now() 
    }) 
}) 

而我得到的错误

Error: no entity to update: app

什么是错我的代码?

回答

5

最有可能的是,event.data.uid的文件不存在。为update()文档状态:

The update will fail if applied to a document that does not exist.

使用set()代替。

+1

你可能真的要调用设置与合并 - 美国商务部的例子就是:cityRef.set({ 资本:真 },{合并:真}) –

+1

的是,火力咱们如果不存在,而更新firestore不... –