I want the new ph value to be added in the arraylist but instead, it keep updating the first value of the arraylist
var insBtn = document.getElementById("InsBtn");
async function AddDocument_CustomID() {
var ref = doc(db,"pHvalue", "pH");
await setDoc(
ref, {
pH: [pH.value]
});
}
insBtn.addEventListener('click', AddDocument_CustomID);
If you want to add a new unique value to the existing values in the pH
array, you can use an array-union
operation :
updateDoc(ref, {
pH: arrayUnion(pH.value)
});
If you instead want to add a possibly non-unique value to the end of the pH
array, you will instead have to:
pH
array from it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.