I have a firebase Object map called "CourseList" which contains nested fields. These nested fields themselves are Object maps which contain further nested fields. Also, some of these object maps will have randomly generated names.
The goal is to delete the Object map with the randomly generated name of "352oIP3fdc6IIvuBbajR0" (underlined in BLUE). The names of "CourseList" and "LectureList" are static names, however the red CourseID (with a randomly generated name of "2dfPipFRKiB6TAKab4jv8").
By following other questions on stackOverflow, I was able to get the delete functionality working if I wanted to delete the Red object map "2dfPipFRKiB6TAKab4jv8".
let CID = '2dfPipFRKiB6TAKab4jv8';
await db.collection('users').doc(UID).set( {
CourseList : { [CID]: FieldValue.delete() }
},{ merge: true }
);
However, when I try to delete the sub-object map underlined in blue of "352oIP3fdc6IIvuBbajR0", the operation appeared to not do anything, and the Firebase document was unchanged.
let CID = "2dfPipFRKiB6TAKab4jv8";
let LID = "352oIP3fdc6IIvuBbajR0";
await db.collection('users').doc(UID).set( {
CourseList : { [`${CID}.LectureList.${LID}`]: FieldValue.delete() }
},{ merge: true }
);
Any clarity as to how to properly delete a deeply nested field inside an object map would be greatly appreciated.
