remove all doc data and add new, if doc is not exist create it
// if id is for non-exist doc, client will generate new id
const cityRef = doc(db, 'cities', 'BJ')
setDoc(cityRef, {
capital: true,
long: false,
title: true
},
// see differences and apply delta, if doc is not exist create it
{ merge: true }
);delete doc
const deleteBookForm = document.querySelector(".delete")
deleteBookForm.addEventListener('submit', e => {
e.preventDefault()
const docRef = doc(db, 'books', deleteBookForm.id.value)
deleteDoc(docRef)
.then(() => {
deleteBookForm.reset()
})
.catch((err) => {
console.error(err.message)
})
})