У меня есть массив на карте, который я хочу обновить с помощью функций Firestore. Моя структура данных выглядит так:
In this case, I want to update the shareRecordsWith array within the {uid} map.
I have been trying to use the following firestore functions but it's not working.
const recordsDict = {"uid": aboutUID, "accessType": accessType}
profilesRef.doc(uid).set({
[uid]: {
{'shareRecordsWith': admin.firestore.FieldValue.arrayUnion(recordsDict)},
{merge: true}
}
});
Is there a way to update an array within a map through Firestore Functions?
EDIT: Based on the suggestions, I changed the function to
profilesRef.doc(uid).set({
[`${uid}.shareRecordsWith`]: admin.firestore.FieldValue.arrayUnion(recordsDict)
}, { merge: true })
Unfortunately, then it adds ${uid}.shareRecordsWith as a new field in the document instead of adding to the shareRecordsWith array within the {uid} map.
This is what it looks like:
введите описание изображения здесь