Google Cloud Functions错误:“无法从Firestore值解码类型" [英] Google Cloud Functions Error: "Cannot decode type from Firestore Value"
问题描述
在React应用中使用Firestore,Im使用Google Cloud Functions进行测试以获取文档字段,然后使用该字段在Firestore中创建一个新字段.前几天我让它工作了,但现在却没有.
Using Firestore in a React app, Im testing out using Google Cloud Functions to grab a document field, and then create a new field in Firestore using that field. I had it working the other day and now it is not.
这是我在Google Cloud Function日志中得到的错误:
This is the error that Im getting in the Google Cloud Function log:
错误:无法从Firestore值中解码类型:{"stringValue":"sox"} 在DocumentSnapshot._decodeValue
Error: Cannot decode type from Firestore Value: {"stringValue":"sox"} at DocumentSnapshot._decodeValue
下面是我使用的代码.它与此处的代码非常相似: https://firebase.google .com/docs/firestore/extend-with-functions#writing_data
Below is the code I used. It is very similar to the code here: https://firebase.google.com/docs/firestore/extend-with-functions#writing_data
exports.createShowDoubleName = functions.firestore
.document('shows/{showId}')
.onUpdate((event) => {
const data = event.data.data();
const previousData = event.data.previous.data();
if (data.name == previousData.name) return;
var name = data.name;
var newname = name+"_"+name
return event.data.ref.set({
newname: newname
}, {merge: true});
});
推荐答案
firebase-functions SDK version 0.7.5 is supposed to fix the problem. It now forces a peer dependency on firebase-admin 5.5.0. Get it:
npm install firebase-functions@0.7.5
这篇关于Google Cloud Functions错误:“无法从Firestore值解码类型"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!