我需要在我的反应应用程序中删除Firestore文档中的字段,Firebase documentation提到我应该使用'firebase-admin'中的FieldValue:
// Get the `FieldValue` object
var FieldValue = require("firebase-admin").firestore.FieldValue;
但是当我试图像这样得到FieldValue对象时,我收到一个错误:
TypeError:existsSync不是函数./node_modules/grpc/node_modules/node-pre-gyp/lib/pre-binding.js/exports.find
我在控制台中也看到了一些警告:
./node_modules/grpc/node_modules/node-pre-gyp/lib/util/versioning.js 16:20-67严重依赖:依赖的请求是表达式./node_modules/google-gax/node_modules/grpc/ node_modules / node-pre-gyp / lib / util / versioning.js 16:20-67严重依赖:依赖的请求是表达式./node_modules/grpc/node_modules/node-pre-gyp/lib/pre-binding .js 19:22-48关键依赖:依赖的请求是一个表达式./node_modules/google-gax/node_modules/grpc/node_modules/node-pre-gyp/lib/pre-binding.js 19:22-48关键依赖:依赖的请求是表达式./node_modules/google-gax/node_modules/grpc/src/grpc_extension.js 30:14-35关键依赖:依赖的请求是表达式
这可能是什么问题?
1 回答
firebase-admin节点模块用于服务器端节点进程 . 您正试图在客户端React应用程序中使用它,这不会起作用 .
在客户端React中,您应该使用常规Firebase JavaScript / Web SDK并使用that tab in the docs中的代码段:
//从文档中删除“大写”字段
var removeCapital = cityRef.update({
capital:firebase.firestore.FieldValue.delete()
});