[I want to update specific index of firestore database via javascript i tried alot but there is no way for me :(
const ref = firestore
.collection('collections')
.doc("dsflkjeowjjljsd3Xfkl")
.items.doc(productIndex);
ref
.update(
{
[`items.${productIndex}`]: fieldUnion({...objectToUpdate, id: productId}),
},
{merge: true}
) // sets the contents of the doc using the id
.then(() => {
// fetch the doc again and show its data
ref.get().then((doc) => {
console.log(doc.data()); // prints {id: "the unique id"}
});
});