imtiajrex/appflare-skills/appflare-querying
Claude Code and agent skill by imtiajrex/appflare-skills
- community
Checking that the SKILL.md file is still in the repository.
Read and write data in Appflare handlers with the typed ctx.db API, including findMany and findFirst with where operators (eq, in, gt, contains/startsWith/endsWith, exists, includes, geoWithin) and and/or/not combinators, relation loading and filtering with "with", orderBy, limit/offset, iterate and cursor pagination, insert with nested relations, update with increment/decrement expressions and expectRows guards, atomic batch and transaction writes, upsert with target/set, delete, count, sum, avg, min, max and groupBy aggregates, and the ctx.$db raw Drizzle escape hatch. Use when writing database logic, filters, search, joins, pagination, counters, aggregates, upserts, transfers or bulk updates inside Appflare query, mutation, scheduler or cron handlers.
Install
npx vskill@latest install imtiajrex/appflare-skills/appflare-queryingSKILL.md
The same SKILL.md was published earlier as imtiajrex/appflare-skills/appflare-querying.
Appflare data access (ctx.db)
Default patterns
Procedure
- Check the schema for the table name (the key in
schema({...})) and the field names. Relation FKs are<relation>Id. - Put every filter in
where. For optional filters, spread them in conditionally and never passundefinedvalues. - Load related rows with
with. To filter parents by related rows, use the relation name insidewhere. - For lists, add
orderByandlimit. For pages, return{ rows, nextCursor, hasMore }. For full scans, useiterate. - For writes, scope
updateanddeletewithwhere, and check the returned array length to detect "not found". - When several writes must all land or none, wrap them in
ctx.db.batch(writes known up front) orctx.db.transaction(writes that depend on a read).
Counters, money and other concurrent writes
Never read a value, compute in JS, then write it back. Let SQL do it:
Atomic multi-table writes
Cursor pagination template
Gotchas
findManyreturns 100 rows by default and rejectslimitabove 1000. Passlimit, or useiterateto walk everything.updateanddeletethrow without a filter. PassallowAll: truewhen you really mean every row. Awherewhose values are allundefinedcounts as empty.- Unknown `where` keys throw. Check spelling and use FK fields (
ownerId), not relation names, for id equality. contains/startsWith/endsWithare substring matches with%and_escaped;regexis an alias ofcontains, not a real regex. Addoptions: "i"for case-insensitive.- Use
or/and/notfor boolean logic.or: []matches nothing. - Every write method returns an array. Destructure (
const [row] = …) and check forundefined. expectRowsfailing throwsAppflareConflictErrorand writes nothing, including the rest of a batch.- Inside
ctx.db.transaction, writes return handles, not promises: readhandle.rowsafter the transaction resolves, and do reads before queuing writes because reads don't see them. upsertdefaultstargetto"id"; withoutset, each conflicting row updates with its own values.ctx.$dbis still available for raw Drizzle, but it skips runtime defaults, JSON handling and realtime events. Preferctx.db.v.date()filters acceptDateor epoch milliseconds._count/_avginsidewithadd<relation>Aggregate(e.g.row.commentsAggregate.count) and are computed in JS; prefergroupByfor large relations.
References
- Read references/where-operators.md when building non-trivial filters: all operators, combinators, relation filters, JSON array and object filters, dates, geo distance, ordering, iterate.
- Read references/writes.md when inserting nested relations, using expressions or guards, batching, transacting, updating many-to-many links (
items/mode) or upserting. - Read references/aggregates.md when computing counts, sums, averages, min/max or grouped results.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/appflare-querying/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/imtiajrex/appflare-skills/appflare-querying)