google-cloud-firestore - Firestore .set 不保存来自 Firebase 云功能的数据
问题描述
我正在尝试将我的表单中的数据保存在 Firestore 中。集合用户已经存在,并且文档“电子邮件”也已经存在。它没有保存,也没有给出任何错误或消息。任何想法为什么会发生?我可以从另一个页面保存数据。我复制了相同的 const admin = require('firebase-admin'); 和 const db = admin.firestore();
到这个页面也是如此,完全一样。不工作:
let setDoc = db
.collection('users')
.doc(email)
.set({'abc':'def'},{merge: true});
// .set(Encdata,{merge: true})
return setDoc.then(res => {
console.log('Set: ', res);
})
.catch(error => {
console.log(error);
});
从另一个页面工作:
let setA = docRef.set({
'username': encDec.encrypt(user_name),
'password' : encDec.encrypt(password),
'email': email,
'uid': UserID
});```
Before and After I trigger the function, data remains the same. All instructions in the function execute fine UNTIL the control reaches the "let setDoc = db" line. After that everything just silently quits.
解决方案
从您的描述和代码来看,您似乎打算覆盖单个文档。根据 Add data to Cloud Firestore 文档设置一个文档以覆盖单个文档,第一个设置方法适合这种情况。
推荐阅读
- kubernetes - 如何列出一个不存在的命名空间的所有对象?
- python - 如何将单元格数据转换为 .vtu 文件中的点数据
- admob - 我需要在 AdMob 中更改软件包名称
- python-3.x - 如何在 jupyter notebook 中仅导出 pdf 格式的输出?
- python - 我想从同一个文件python的不同工作表中获取一些数据
- javascript - 没有服务器的网络工作者
- .net - 控制器中的JQuery ajax发布参数为空
- c# - 过滤自动完成列表中的数据
- javascript - 如何从组件初始化Angular服务,自定义类?
- python - 如何对里面有列表的字典进行排序?