错误:无实体可更新:应用程序

编程入门 行业动态 更新时间:2024-10-27 20:30:14
本文介绍了错误:无实体可更新:应用程序-Firestore Cloud功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是我非常基本的Cloud Function:

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() }) })

我得到了错误

错误:没有要更新的实体:应用

Error: no entity to update: app

我的代码有什么问题?

推荐答案

event.data.uid的文档很可能不存在. update()的文档指出:

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.

改为使用 set().

更多推荐

错误:无实体可更新:应用程序

本文发布于:2023-11-22 05:15:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1616109.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   实体   错误

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!