- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下功能:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const FieldValue = require('firebase-admin').FieldValue;
module.exports = functions.firestore
.document('students/{studentId}')
.onDelete(event => {
const student = event.data.previous.data();
const { id, semester } = student;
const classId = student.class;
const deleteObj = {};
deleteObj[id] = FieldValue.delete(); //Line 12, this is where the error orccurs
return admin
.firestore()
.collection('semesters')
.doc(semester)
.collection('students')
.doc(classId)
.update(deleteObj);
});
每次运行时都会出现以下错误:
TypeError: Cannot read property 'delete' of undefined
at module.exports.functions.firestore.document.onDelete.event (/user_code/deleteStudent.js:12:37)
查看docs我真的看不出我做错了什么?
// Get the `FieldValue` object
var FieldValue = require("firebase-admin").FieldValue;
// Create a document reference
var cityRef = db.collection('cities').doc('BJ');
// Remove the 'capital' field from the document
var removeCapital = cityRef.update({
capital: FieldValue.delete()
});
更新
因此,使用网络等效项似乎可行:admin.firestore.FieldValue.delete()
。但这似乎是一个错误,因为我处于 Nodejs 环境中?任何 Firebaser 都可以确认或否认情况是否如此吗?我很乐意提交错误报告。
最佳答案
事实证明这是文档中的错误,正确的导入应该是 const FieldValue = require('firebase-admin').firestore.FieldValue;
更新
应该说,Firebase 在数小时内做出了响应,并正在尽快更正文档。
关于javascript - 使用函数和 Firestore 时 FieldValue 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47091940/
As per Firebase documentation, we should not use incremental values as it may cause hotspots.I ha
根据Firebase文档,我们不应该使用增量值,因为它可能会导致热点。我有多个子集合,并且我只对对子集合进行排序感兴趣,所以我希望将服务器端时间戳与文档ID(它表示我的子集合所在的文档)连接在一起。但
我在我的 React 应用程序中使用 firestore。它在尝试获取/创建/更新文档时没有任何问题。但是我无法访问我需要使用 arrayUnion 更新数组的 FieldValue。我使用的 fir
我必须在firebase firestore中增加一个值,数据看起来像这样 { "key":{ "name":"Apple", "quantity":12 } }
例如我有这样一个文档: team: { members: [{name: "john", age: 2}, {name: "tim", age: 3}] } 我想将 Tims 年龄更新为 4 {nam
我有一个具有以下结构的文档: { "email" : "a@gmail.com", "value" : 100, "children" : [
我有以下功能 Future _updateDocument(String path, {Map data}) async { final Map stampedData = {'updat
我将用户的 Firebase 云消息注册 token 存储在 Firestore 用户集合中,每当我发送通知时,我都会删除未使用的 token 。我正在使用 admin sdk 在云功能上执行此操作。
Firestore 的 FieldValue.increment(someValue) 可以与其他字段正常配合使用,但不能与 map 配合使用。 我正在尝试增加 map 中属性的值。我有一个名为用户的
我试图通过使用反射来避免对配置类的序列化进行硬编码,但我遇到了一种我无法解决任何问题的情况。这就是我想要做的。 我有这样一个类 public class Configuration { publ
在我的 Typescript 应用程序代码中,我定义了一个模型,该模型使用 Firestore 在服务器上生成的时间戳。当文档从数据库返回时,该字段将是一个 ISO 字符串。我想在我的整个应用程序中使
我正在尝试从我在 FireStore 中声明的 map 中删除用户。但是如何获取字段值?我认为它应该是这样的 firestore.FieldValue.arrayRemove(user.uid) 只有
这是我的数据库: 如何在私有(private) map 下删除 lotteryID 中的键“2”?我试过这个: db.collection("users").document(currentUser.
我正在尝试从Firestore数据库中的列表中删除元素,但是它不起作用。我发现奇怪的是,FieldValue.arrayUnion()和FieldValue.delete()正常工作。为什么只有Fie
我已经在文档中的集合中创建了一个审阅系统。在文档中,我有一个数组,其中的平均评分为(在上传评论时添加了评分),但是如果我使用FieldValue.arrayUnion上传两个相等的数字,我只会得到一个
我正在尝试使用客户端对象模型 (CSOM) 从 SharePoint 中提取所有项目信息。以下是我获取项目信息的方式: projectContext.Load(projectContext.Proje
我正在 firestore 中构建一个实时聊天应用程序,我目前在读回消息时间戳时遇到问题。我正在使用 onSnapshot 监听器从我的消息集合中获取更新,但是我发现我在最新的时间戳上收到未定义的错误
我尝试使用react-native-firebase的增量方法来增加数字字段,但它一直给我以下错误: No static method increment(D)Lcom/google/firebase
我有可以正常工作的初始数据。 var data = {field1: FieldValue.increment(1)}; 当我向数据中添加另一个字段时也很好。 data.addAll({field2:
通过 meteor 自动形成, 我可以得到标签 {{> afFieldLabel name="myLabelName"}} 我还可以自动生成输入框 {{> afFieldInput name="myL
我是一名优秀的程序员,十分优秀!