Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Firebase云函数未设置新文档_Node.js_Google Cloud Firestore_Firebase Authentication_Google Cloud Functions - Fatal编程技术网

Node.js Firebase云函数未设置新文档

Node.js Firebase云函数未设置新文档,node.js,google-cloud-firestore,firebase-authentication,google-cloud-functions,Node.js,Google Cloud Firestore,Firebase Authentication,Google Cloud Functions,当用户在我的应用程序中注册时,Firebase云功能将在临时用户集合中存储authUid和emailAddress,直到用户验证其电子邮件地址。验证后,云功能将在users集合中创建新文档,并在temporaryUsers集合中删除用户的临时文档 一切正常(临时文档在验证后正确删除)除了未在users集合中创建的用户文档。由于某些原因,未创建此文档。 也许有人对我如何在这个云函数中更好地进行错误检查提出了一些建议?或者,有人在我的代码中发现任何问题/错误吗?以下是云函数(下面有一些日志详细信息)

当用户在我的应用程序中注册时,Firebase云功能将在
临时用户
集合中存储
authUid
emailAddress
,直到用户验证其电子邮件地址。验证后,云功能将在
users
集合中创建新文档,并在
temporaryUsers
集合中删除用户的临时文档

一切正常(临时文档在验证后正确删除)除了未在
users
集合中创建的用户文档。由于某些原因,未创建此文档。


也许有人对我如何在这个云函数中更好地进行错误检查提出了一些建议?或者,有人在我的代码中发现任何问题/错误吗?以下是云函数(下面有一些日志详细信息):

confirmEmail.js

日志:

将try/catch添加到
confirmEmail.js
后的其他日志:


我想出来了。这是我的一个错误。我正在观看firebase firestore控制台,并通过
createdAt
属性过滤数据……但新数据没有显示,因为我的
confirmEmail.js
函数没有添加
createdAt
属性:

    const docRef = await store.collection('users').doc(authUid).set({
      emailAddress,
      displayName,
      createdAt <---- i forgot this 
    })
const docRef=wait store.collection('users').doc(authUid).set({
电邮地址:,
显示名称,

createdAt“也许有人对如何在这个云函数中更好地执行错误检查有一些建议”=>使用
try/catch
console.log()
。我一眼就看不到你的代码中有任何问题。你确定
authUid
的值正确吗?让我调查一下,然后回来。Thx!@RenaudTarnec:我添加了一个try/catch(参见上面编辑的代码)我现在在日志中看到的唯一一件事是:
doc updated!WriteResult{{u writeTime:Timestamp{u seconds:1609255658,{u纳秒:835622000}
。也没有向
用户
集合添加新的用户文档。我找到了它。这是一个缺少的参数,我需要从临时文件夹转到用户文件夹。将用答案更新我的问题。感谢帮助!

5:53:42.241 AM
confirmEmail
Function execution took 4824 ms, finished with status code: 302
5:53:37.418 AM
confirmEmail
Function execution started
5:52:49.984 AM
sendVerificationEmail
Function execution took 3400 ms, finished with status: 'ok'
5:52:49.981 AM
sendVerificationEmail
it works
5:52:46.585 AM
sendVerificationEmail
Function execution started
5:52:45.389 AM
createAccount
Function execution took 4568 ms, finished with status code: 200
5:52:43.796 AM
createAccount
}
5:52:43.796 AM
createAccount
createdAt: 1609242763793
5:52:43.796 AM
createAccount
confirmationHash: '38563d53-be8e-4402-8f21-fb0260e3d7d4',
5:52:43.796 AM
createAccount
emailAddress: 'redacted@gmail.com',
5:52:43.796 AM
createAccount
displayName: 'doss',
5:52:43.796 AM
createAccount
authUid: 'EMUxT8qYz4SJJqKILHt0QU70iZy2',
5:52:43.796 AM
createAccount
tempUserInfo from createTemporaryUserJs: {
5:52:40.822 AM
createAccount
Function execution started
5:52:40.747 AM
createAccount
Function execution took 13 ms, finished with status code: 204
5:52:40.735 AM
createAccount
Function execution started
    const docRef = await store.collection('users').doc(authUid).set({
      emailAddress,
      displayName,
      createdAt <---- i forgot this 
    })