How to update a collection using cloud function?
问题 I would like to update the score using a cloud function I've tried this so far exports.rate = functions.https.onRequest((request, response) => { admin .firestore() .collection() .where("index", "==", request.index) .get() .then(snap => { snap.forEach(x => { const newRating = x.data().score + request.value; firebase .firestore() .collection() .doc(x.id) .update({ score: newRating }); }); }); }); 回答1: The following should work: exports.rate = functions.https.onRequest((request, response) => {