FrontierJS

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

In depth: Gotchas § Soft delete and findUnique, and the full list