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.
This is the error that Im getting in the Google Cloud Function log:
Error: Cannot decode type from Firestore Value: {"stringValue":"sox"} at DocumentSnapshot._decodeValue
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});
});