Real-time database operations with Firestore.
const docRef = await addDoc(
collection(db, 'items'),
{
name: 'My Item',
description: 'Description',
createdAt: new Date()
}
); const q = query(
collection(db, 'items'),
where('name', '==', 'My Item')
);
const snapshot = await getDocs(q);
snapshot.forEach(doc => {
// Process doc
}); await updateDoc(
doc(db, 'items', docId),
{
description: 'Updated'
}
); await deleteDoc( doc(db, 'items', docId) );