I am trying to do an update to a Firebase firestore document. However, I am getting the error
Property 'update' does not exist on type 'DocumentReference'
const Firestore = initializeFirestore(Firebase);
const vendorsRef = collection(Firestore, '/vendors');
const q = query(vendorsRef, where("uuid", "==", vendorUuid))
const querySnapshot = await getDocs(q);
querySnapshot.forEach(async (doc) => {
const delRes = await doc.ref.update({deleted: '06-02-2022'}); // doing soft delete
});
Any suggestions as to why this is? When I did into the node_modules, the update function appears to be there. Seems like a typescript issue maybe? I have also tried doing it the other style I've found where I use
Firestore.collection('vendors').doc('something').set(data);
But in that style, it tells me that Property 'collection' does not exist on type 'Firestore'
The error is telling you that there is no method "update" on v9 DocumentReference. If you look through the linked API doc, you will see that is definitely the case.
It seems you are maybe mixing up the JavaScript v8 and v9 APIs. v8 does have update as a method on DocumentReference but v9 does not. If you want to update a document using v9 as you are currently using, you should follow the documentation for that and use the updateDoc function.
import { updateDoc } from "firebase/firestore";
await updateDoc(doc.ref, {deleted: '06-02-2022'});