错误:没有要更新的实体:app - Firestore Cloud Function [英] Error: no entity to update: app - Firestore Cloud Function
本文介绍了错误:没有要更新的实体:app - Firestore Cloud Function的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我最基本的云功能:
const functions = require('firebase-functions');const admin = require('firebase-admin');admin.initializeApp(functions.config().firebase);const db = admin.firestore()export.createdNewAccount = functions.auth.user().onCreate(event => {返回 db.collection('users').doc(event.data.uid).update({"creationDate" : Date.now()})})
我得到了错误
<块引用>错误:没有要更新的实体:app
我的代码有什么问题?
解决方案
很可能,event.data.uid
的文档不存在.update() 的文档指出:
如果应用于不存在的文档,更新将失败.
请改用 set().p>
This is my very basic Cloud Function:
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()
})
})
And I get the error
Error: no entity to update: app
What is wrong with my code?
解决方案
Most likely, the document for event.data.uid
does not exist. The documentation for update() states:
The update will fail if applied to a document that does not exist.
Use set() instead.
这篇关于错误:没有要更新的实体:app - Firestore Cloud Function的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文