Skip to content

Database and HTTP conventions

ConventionNotes
Query priorityPrefer kdb (Drizzle object queries); for quick CRUD use db.insert / findAll; drop to hand-written SQL for complex aggregation
ParametersAlways parameterize hand-written SQL with $1; never concatenate strings
IdentifiersTable / column names are whitelist-validated
Auto-increment idUse .returning({ id: table.id }) on insert / update / delete
BLOBReturned as base64 strings; decode with atob on the frontend
TransactionsUse runInTransaction([{ sql, params }]) for atomic multi-statement writes

See Database and migrations for details.

Always go through @/core/http (Rust reqwest, no CORS); never fetch cross-origin data inside the webview:

import { http } from '@/core/http';
const data = await http.getJson<MyResponse>('https://api.example.com/items');
const res = await http.postJson<Res>('https://api.example.com/items', { title: 'x' });

Features: global singleton, rustls, cookie session, 10 redirects, a 30 s timeout and a 10 MB response cap; http.download() streams to a file with progress; proxy settings are respected.