this code will overwrite the entire map in firestore
Map<String, String> map = {};
for (MapEntry e in someGientMap.entries) {
map[e.key] = e.value;
}
await db.doc('document path').update({
'FirestoreGiantMap': map,
});
and this code will write the document too many times
for (MapEntry e in someGientMap.entries) {
await db.doc('document path').update({
'FirestoreGiantMap.${e.key}: e.value,
});
}
CodePudding user response:
You're almost there. Combing the two techniques leads to:
Map<String, String> map = {};
for (MapEntry e in someGientMap.entries) {
var key = 'FirestoreGiantMap.' e.key;
map[key] = e.value;
}
await db.doc('document path').update(map);