Litestone guide / Misc
Gotchas
SQLite and Litestone each do a few things a newcomer does not expect. They are all correct, measured and listed with an example in the full page.
model User {
id Int
name String
deletedAt DateTime?
}
const u = await db.user.create({ data: { name: 'a' } })
await db.user.remove({ where: { id: u.id } })
const hidden = await db.user.findUnique({ where: { id: u.id } })
const found = await db.user.findUnique({ where: { id: u.id }, withDeleted: true })
if (hidden !== null || found?.name !== 'a') throw new Error('expected the soft-deleted row to need withDeleted')
remove() soft-deletes and findUnique then hides the row. delete() is the physical delete on any model.
What else it can do
LIKEandlower()fold ASCII only, socontains: 'émile'does not matchÉmilejson_extractreturns native types, so a number compared to a string matches nothing- A lone
Int @idisAUTOINCREMENT, and a gap in ids is normal notInandnotincludeNULLrows, unlike plain SQLBooleanis stored as0/1and coerced on readDateTimeis ISO-8601 text, so comparison works and arithmetic needs care- Overlapping deploys on one WAL file can contend for the write lock
kamal app execadds a container of memory per invocationselect: falsestill reads the row on a@@trailmodel@sequencerolls back with its transaction and reuses the numberJson @encryptedround-trips, and an older database may hold'[object Object]'- The audit trail lags a write by one event-loop tick
- A relative
database { path }resolves against the process directory, not the schema
In depth: Gotchas § Soft delete and findUnique, and the full list