1-- name: CreateSession :one
2INSERT INTO sessions (
3 id,
4 title,
5 message_count,
6 prompt_tokens,
7 completion_tokens,
8 cost,
9 updated_at,
10 created_at
11) VALUES (
12 ?,
13 ?,
14 ?,
15 ?,
16 ?,
17 ?,
18 strftime('%s', 'now'),
19 strftime('%s', 'now')
20) RETURNING *;
21
22-- name: GetSessionByID :one
23SELECT *
24FROM sessions
25WHERE id = ? LIMIT 1;
26
27-- name: ListSessions :many
28SELECT *
29FROM sessions
30ORDER BY created_at DESC;
31
32-- name: UpdateSession :one
33UPDATE sessions
34SET
35 title = ?,
36 prompt_tokens = ?,
37 completion_tokens = ?,
38 cost = ?
39WHERE id = ?
40RETURNING *;
41
42
43-- name: DeleteSession :exec
44DELETE FROM sessions
45WHERE id = ?;