opencode_offline/internal/db/sql/sessions.sql

49 lines
727 B
MySQL
Raw Normal View History

2025-03-24 02:19:08 +08:00
-- name: CreateSession :one
INSERT INTO sessions (
id,
2025-03-28 05:35:48 +08:00
parent_session_id,
2025-03-24 02:19:08 +08:00
title,
message_count,
2025-03-24 05:25:31 +08:00
prompt_tokens,
completion_tokens,
2025-03-24 02:19:08 +08:00
cost,
updated_at,
created_at
) VALUES (
?,
?,
?,
?,
?,
2025-03-24 05:25:31 +08:00
?,
2025-03-28 05:35:48 +08:00
?,
2025-03-24 02:19:08 +08:00
strftime('%s', 'now'),
strftime('%s', 'now')
) RETURNING *;
-- name: GetSessionByID :one
SELECT *
FROM sessions
WHERE id = ? LIMIT 1;
-- name: ListSessions :many
SELECT *
FROM sessions
2025-03-28 05:35:48 +08:00
WHERE parent_session_id is NULL
2025-03-24 02:19:08 +08:00
ORDER BY created_at DESC;
-- name: UpdateSession :one
UPDATE sessions
SET
title = ?,
2025-03-24 05:25:31 +08:00
prompt_tokens = ?,
completion_tokens = ?,
2025-03-24 02:19:08 +08:00
cost = ?
WHERE id = ?
RETURNING *;
-- name: DeleteSession :exec
DELETE FROM sessions
WHERE id = ?;