Database — Update Data
Modify existing rows with a fluent, typed API. Updates are schema‑validated and behave the same on SQLite (Web/Expo) and Supabase.
Prerequisite: You have a client created with a
dbSpec(schema+relations[+ optionalseed,meta]) and an adapter factory for SQLite Web/Expo or Supabase.
Execution Rule
- Writes execute immediately. Calling
.update({...})performs the write. - Always target rows with filters (e.g.,
.where({ id: 3 })or.eq('id', 3)).
Basics
1// Update one user by id
2await db
3 .from('users')
4 .where({ id: 3 }) // or .eq('id', 3)
5 .update({ name: 'Grace Hopper' })Multiple rows
1// Bulk update by membership
2await db
3 .from('posts')
4 .in('id', ['p1', 'p2', 'p3'])
5 .update({ published: true })Partial updates
Only provided fields are patched; payloads are validated against your schema.
1await db
2 .from('users')
3 .eq('email', 'grace@example.com')
4 .update({ name: 'Grace H.' })With ordering / limits (optional)
You can pre‑restrict the target set before updating.
1// Update only the 10 newest draft posts
2await db
3 .from('posts')
4 .eq('published', false)
5 .order('created_at', { ascending: false })
6 .limit(10)
7 .update({ published: true })Types & validation
- Patch objects are validated at runtime against your
dbSpec.schema. - Unknown columns or invalid kinds are rejected early.
- Result types are inferred from the schema.
Summary
Use filters to target rows, call .update({...}) to write immediately, and rely on the schema for validation and types. Same fluent surface across adapters—only storage changes, not your code.