Use Cases

Claude Code के साथ Firestore Schema Design: Collections से पहले Queries

Claude Code से Firestore schema, indexes, cost और security rules को query-first तरीके से design करने की practical guide.

Firestore design queries से शुरू होता है

मैं Masa हूं, claudecode-lab.com चलाता हूं।

Firestore में पहली गलती अक्सर यह होती है कि हम पहले collections सोचते हैं: users, posts, comments। लेकिन वास्तविक screens आने पर समस्या दिखती है: published posts, author page, draft list, tag page. Firestore SQL joins वाली database नहीं है।

बेहतर workflow है: पहले app की queries लिखें, फिर schema बनाएं।

Official references:

claude -p "
CMS के लिए Firestore design करो।
Collections से पहले required queries की table बनाओ।
where/orderBy/limit और composite indexes भी लिखो।
"
export interface PostDoc {
  id: string;
  slug: string;
  title: string;
  status: "draft" | "published" | "archived";
  lang: "ja" | "en" | "es" | "ko";
  authorId: string;
  authorName: string;
  tagSlugs: string[];
  tagNames: string[];
  publishedAt: FirebaseFirestore.Timestamp | null;
  updatedAt: FirebaseFirestore.Timestamp;
}

List screen में extra reads कम करने के लिए authorName और tagNames जैसे छोटे fields duplicate करना practical है। Indexes को Git में रखना चाहिए:

{
  "indexes": [
    {
      "collectionGroup": "posts",
      "queryScope": "COLLECTION",
      "fields": [
        { "fieldPath": "lang", "order": "ASCENDING" },
        { "fieldPath": "status", "order": "ASCENDING" },
        { "fieldPath": "publishedAt", "order": "DESCENDING" }
      ]
    }
  ]
}

मेरे experience में, query table पहले बनवाने से schema review काफी बेहतर हुआ। Claude Code को सीधे code लिखवाने के बजाय पहले query, index, cost और security risks दिखाने दें।

#claude-code #gcp #firestore #database #typescript #query-design
मुफ़्त

मुफ़्त PDF: 5 मिनट में Claude Code चीटशीट

बस अपना ईमेल दर्ज करें और हम तुरंत A4 एक-पृष्ठ चीटशीट PDF भेज देंगे।

हम आपकी व्यक्तिगत जानकारी की सुरक्षा करते हैं और स्पैम नहीं भेजते।

अपने Claude Code वर्कफ़्लो को अगले स्तर पर ले जाएँ

Claude Code में तुरंत कॉपी-पेस्ट करने योग्य 50 आज़माए हुए प्रॉम्प्ट टेम्पलेट।

Masa

लेखक के बारे में

Masa

Claude Code का गहराई से उपयोग करने वाले इंजीनियर। claudecode-lab.com चलाते हैं, जो 10 भाषाओं में 2,000 से अधिक पेजों वाला टेक मीडिया है।