AGENT SKILL
firebase-firestore-data-modeling
Model Firestore data for the queries you actually run, not for normalization
- License 许可
- Apache-2.0
- 所属仓库
- linktogo/maggie
- 最近更新
- 2026-11-14
- Stars
- ★ 2
- Forks
- 2
01 前言 Front Matter
- name
- firebase-firestore-data-modeling
- globs
- [ "**/*.ts", "**/*.js", "firestore.indexes.json" ]
- description
- Model Firestore data for the queries you actually run, not for normalization
03 SKILL.md 正文
Firestore data modeling
Firestore is a NoSQL document store. Model around the reads your app performs; denormalize on purpose rather than mirroring a relational schema.
Rules
- Design collections from your query patterns first. There are no joins — if you need data together, store it together (embed) or duplicate the few fields you render in lists.
- Keep documents small and bounded. Use subcollections for unbounded growth
(a
messagessubcollection under achat) instead of a growing array field. - Every query must be backed by an index. Composite queries need a composite
index declared in
firestore.indexes.json— add it rather than relying on the console's auto-suggest link in production. - Denormalized copies drift: update all copies in a single batched write or a transaction, and keep the write path that maintains them in one place.
- Avoid document-level write hotspots (a single counter hammered by everyone); use distributed counters (sharded) or increment on the server.
- Paginate with cursors (
startAfter(lastDoc)), never largeoffsets — Firestore bills and scans every skipped document.
Anti-patterns
- A relational schema with "foreign key" ids you then N+1 fetch client-side.
- Unbounded arrays inside a document (they must be read/written whole and hit the 1 MiB document limit).
- Reading a whole collection to count it — keep a maintained counter instead.
04 同仓库更多 Skills
vuejs-state-management
Manage Vue application state with Pinia and the right state locality
★ 2
vuejs-composition-api
Write Vue 3 components with the Composition API, script setup, and composables
★ 2
reactjs-hooks
Use React hooks correctly — dependencies, effects, and custom hooks
★ 2
reactjs-component-design
Write small, composable React components with clean props and no needless state
★ 2
postgres-query-performance
Diagnose and fix slow PostgreSQL queries with indexes and EXPLAIN
★ 2
postgres-migrations
Write safe, reversible, zero-downtime PostgreSQL schema migrations
★ 2