I want to update a product of my products array.
I have an array of products in a collection
products[{
- 0
productPrice: 123
- 1
productPrice: 432
}]
In my code I have passed the position of the element I want to update in that array of products
suspend fun updateProductPrice(position:Int,shopId: String,price: Int): Resource<Unit> {
FirebaseFirestore.getInstance().collection("shops").document(shopId).update("products"[position]) //here I need to get productPrice and update its value to the price parameter in my method
return Resource.Success(Unit)
}
I need to update that productPrice (at the position 0) value whiting that array, but I dont find how
Thanks !