examples/sqlite-raw/README.md
This example demonstrates using the raw SQLite driver with RivetKit actors.
git clone https://github.com/rivet-dev/rivet.git
cd rivet/examples/sqlite-raw
npm install
npm run dev
@rivetkit/db/rawonMigrate to create tables on actor wakepnpm install
pnpm dev
The example creates a todoList actor with the following actions:
addTodo(title: string) - Add a new todogetTodos() - Get all todostoggleTodo(id: number) - Toggle todo completion statusdeleteTodo(id: number) - Delete a todosrc/registry.ts - Actor definition with database configurationsrc/server.ts - Server entry pointThe database uses the KV-backed SQLite VFS, which stores data in a key-value store. The schema is created using raw SQL in the onMigrate hook:
db: db({
onMigrate: async (db) => {
await db.execute(`
CREATE TABLE IF NOT EXISTS todos (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
completed INTEGER DEFAULT 0,
created_at INTEGER NOT NULL
)
`);
},
})
MIT