我想更新completedFirestore 中數組中對象的屬性,但我不知道如何訪問數組中的特定元素。圖像將顯示結構。我已經走到了這一步,但不知道如何選擇,例如數組中的第 1 項。我正在考慮使用它的 ID(它有一個 id 屬性),但不知道如何到達那里。const businessRef = db.collection('approvedBusinesses').doc(businessId) try { businessRef.update({ [`bookings.${currentDate} ????? `]: true // what to add after currentDate? })順便說一句,這就是數組的創建方式(以及其他對象被推送到它的方式)const bookingObj = { carro: 'PASSA_CARRO', completed: false, userId: userObject.uid, }businessRef.update({ [`bookings.${currentDate}`]: firebase.firestore.FieldValue.arrayUnion(bookingObj), })
如何更新firestore中數組內的對象?
精慕HU
2022-10-08 10:28:53