so I have callable cloud function like this:
const db = admin.firestore()
exports.changeEventDataInUserSubcollection = functions.https.onCall(async (data, context) => {
const updatedKey = data.updatedKey
const updatedValue = data.updatedValue
const creatorID = data.creatorID
const eventID = data.eventID
try {
return db.doc(`users/${creatorID}/createdEvents/${eventID}`).update({updatedKey: updatedValue})
} catch (error) {
console.log(error)
return Promise.resolve(null)
}
})
as you can see in .update({updatedKey: updatedValue})
, I want to set the key and value from the client side. so I can update the document dynamically. I want the updatedKey
and updatedValue
come from client side
but my code above seems will not work, because I have this warning:
updatedKey
is declared but never used. so how to dynamically change the key and value when updating Firestore document ? can I do that ?