Skip to content

Add local queries & mutations for offline-first#66

Merged
Jds-23 merged 1 commit into
mainfrom
feat/local-queries-mutations
Mar 1, 2026
Merged

Add local queries & mutations for offline-first#66
Jds-23 merged 1 commit into
mainfrom
feat/local-queries-mutations

Conversation

@Jds-23

@Jds-23 Jds-23 commented Mar 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add local SQLite query functions for workouts, sessions, and metrics with Drizzle relational queries and soft-delete filtering
  • Add mutation functions that write locally via syncWrite() (atomic local insert + sync queue entry)
  • Add queryKeys factory and invalidateAfterPull() to broadly invalidate TanStack Query caches after sync pull
  • Wire invalidateAfterPull into SyncProvider after successful sync

New files

  • lib/queries/workouts.tsgetWorkouts, getWorkoutById
  • lib/queries/sessions.tsgetSessions (with totalSetsDone/totalVolume), getSessionById
  • lib/queries/metrics.tsgetMetricDefinitions, getMetricEntries (with date range filter)
  • lib/mutations/workouts.tscreateWorkout, updateWorkoutTitle, addExercise, removeExercise, updateExercise, addSet, removeSet, deleteWorkout
  • lib/mutations/sessions.tscreateSession, deleteSession
  • lib/mutations/metrics.tsupsertMetricDefinition, upsertMetricEntry, deleteMetricDefinition, deleteMetricEntry
  • lib/query-keys.ts — query key factory + invalidateAfterPull
  • Barrel exports for queries/ and mutations/

Test plan

  • 31 new tests across 6 test files — all passing
  • All 235 existing + new native tests green
  • pnpm check clean (0 errors)

Closes #50

🤖 Generated with Claude Code

Wire all reads from local SQLite via Drizzle relational queries and all
writes through syncWrite() for atomic local + sync queue operations.
Covers workouts, sessions, and metrics with soft-delete filtering,
computed stats, and broad query invalidation after sync pull.

Closes #50

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Jds-23 Jds-23 merged commit 04c9513 into main Mar 1, 2026
1 of 4 checks passed
@Jds-23 Jds-23 deleted the feat/local-queries-mutations branch March 1, 2026 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wire local queries and mutations for offline-first

1 participant