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不... –