Quería saber cómo podemos almacenar elementos (mapa) dentro de un mapa con nombres de elementos dinámicos. Intenté lo siguiente
var activequestionid = "12201" var aqid = "answers."+activequestionid await updateDoc((doc(db, "tests", testid), { [`${aqid}`]: {ans:ans,type:type,time:serverTimestamp()} })) var activequestionid = "12201" var aqid = "answers."+activequestionid await updateDoc((doc(db, "tests", testid), { [aqid]: {ans:ans,type:type,time:serverTimestamp()} }))También mi mapa es el siguiente:
testid(document) answers(map) 12201(map) Pero ambos dan el mismo error: Expected type 'Pc', but it was: a custom Object object cualquier ayuda sobre este problema!
La función updateDoc() toma 2 parámetros: una DocumentReference y los datos. Tiene () alrededor de ambos, así que esencialmente es 1 parámetro. Prueba a eliminarlos:
var activequestionid = "12201" var aqid = "answers."+activequestionid await updateDoc( doc(db, "tests", testid), { [aqid]: { ans: ans, type: type, time: serverTimestamp() } })