Models, queries and caching
Model storage
Section titled “Model storage”Each app has a private SQLite database on a retained volume. Generated model tables store checked JSON records and selected field indexes. User/session state shares this database in fresh native apps. File bytes use the separate account object backend; references stay with model data.
New apps use the qualified WAL configuration and one writer. Normal update preserves compatible schemas. Arbitrary schema migration and writable replicas are not current promises.
Create and read
Section titled “Create and read”The Counter example creates a record with the current app user:
return database.counters.create(Counter{ name: input.name, owner: auth.user.id, value: 0,})Its list scopes rows to that same user:
return database.counters. where(owner == auth.user.id). order(updatedAt, desc). all()The supported query layer includes checked scalar filters, ordering, limits, terminal reads and selected mutations. It normalizes selected time, date and duration values and preserves signed 64-bit integers. Read the full status matrix before using broader query expressions.
Unique conflicts return HTTP 409. Generated input validation rejects unsupported fields, invalid types, enums and constrained string lengths. Model and index names must not collide with system or generated schema names.
Update with ownership
Section titled “Update with ownership”// @api POST /counters/:id/increment// @auth user owns Counter.owner// @cache invalidate ListCountersfunc IncrementCounter(id ID) Counter { counter := database.counters.get(id) counter.value = counter.value + 1 counter.updatedAt = now()
updated := database.counters.update(counter) emit(CounterIncremented{ counter: updated.id, owner: updated.owner, value: updated.value, }) return updated}This excerpt uses the CounterIncremented event declared in the
complete Counter source.
The lowered function uses one SQLite transaction. Auth checks use the current
user and role in that transaction. A client-selected owner header grants no access.
Response caching
Section titled “Response caching”The Counter list declares @cache 30s key=user. Cache keys stay inside the app.
A successful mutation invalidates the declared target. Concurrent stale fills
cannot replace the new generation. Restart clears the memory cache.
Cache behavior is app-local. Distributed invalidation is not supported. Ownership routes reject TTL caching. Generated caches have memory limits; missing resource metrics do not prove zero usage.