I want to update a map in Firestore using cloud Function typed in Typescript, so I made this code but it doesn't work:
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
admin.initializeApp(functions.config().firebase);
exports.sendNote = functions.https.onCall(async(data,context)=>{
const numeroSender: string = data['numeroSender'];
const amisA = admin.firestore().collection('Amis').doc(numeroReceiver);
const connaissanceABBA:number = 3.0;
const version:number = 1;
await amisA.update({
'amis.${numeroSender}' : [connaissanceABBA,version]
});
});
the editor doesn't replace numeroSender by its value, and I tried also with:
'amis.'+numeroSender
and the editor is asking a semicolon and show many other errors. Even I tried to try this way:
const mapA: string = ("amis."+numeroSender);
console.log(mapA);
await amisA.update({
mapA : [connaissanceABBA,version]
});
the console shows the correct string, but update function doesn't read mapA value but executes with string 'mapA'.