firestore_patterns
Firebase Firestore NoSQL patterns, real-time sync ve security rules rehberi.
npxskills add vuralserhat86/antigravity-agentic-skills--skill firestore_patternsLoading…
Firebase Firestore NoSQL patterns, real-time sync ve security rules rehberi.
npxskills add vuralserhat86/antigravity-agentic-skills--skill firestore_patternsLoading…
Firebase Firestore NoSQL patterns rehberi.
import {
collection, doc, getDoc, setDoc,
addDoc, updateDoc, deleteDoc, query, where
} from 'firebase/firestore';
// Read
const docRef = doc(db, 'users', 'userId');
const docSnap = await getDoc(docRef);
// Create
await setDoc(doc(db, 'users', 'userId'), { name: 'John' });
await addDoc(collection(db, 'users'), { name: 'John' }); // Auto ID
// Update
await updateDoc(doc(db, 'users', 'userId'), { name: 'Jane' });
// Delete
await deleteDoc(doc(db, 'users', 'userId'));
import { onSnapshot } from 'firebase/firestore';
const unsubscribe = onSnapshot(
doc(db, 'users', 'userId'),
(doc) => {
console.log('Data:', doc.data());
}
);
// Cleanup
unsubscribe();
const q = query(
collection(db, 'users'),
where('age', '>=', 18),
where('status', '==', 'active'),
orderBy('createdAt', 'desc'),
limit(10)
);
const querySnapshot = await getDocs(q);
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow read: if request.auth != null;
allow write: if request.auth.uid == userId;
}
}
}
Firestore Patterns v1.1 - Enhanced
Kaynak: Firebase Security Rules Guide
request.auth != null kontrolünü her kurala ekle.| Aşama | Doğrulama |
|---|---|
| 1 | Bir dökümanı okumak için 100 başka döküman okumak gerekiyor mu? (Kötü) |
| 2 | Herkesin yazabildiği (allow write: if true) bir yer kaldı mı? (Kritik) |
| 3 | Sorgular index hatası veriyor mu? |
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Set up and use 1Password CLI (op). Use when installing the CLI, enabling desktop app integration, signing in (single or multi-account), or reading/injecting/running secrets via op.
CLI to manage emails via IMAP/SMTP. Use `himalaya` to list, read, write, reply, forward, search, and organize emails from the terminal. Supports multiple accounts and message composition with MML (MIME Meta Language).
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Set up and use 1Password CLI (op). Use when installing the CLI, enabling desktop app integration, signing in (single or multi-account), or reading/injecting/running secrets via op.
CLI to manage emails via IMAP/SMTP. Use `himalaya` to list, read, write, reply, forward, search, and organize emails from the terminal. Supports multiple accounts and message composition with MML (MIME Meta Language).