diff options
Diffstat (limited to 'internal/db/sql/sessions.sql')
| -rw-r--r-- | internal/db/sql/sessions.sql | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/internal/db/sql/sessions.sql b/internal/db/sql/sessions.sql new file mode 100644 index 000000000..e90e5e328 --- /dev/null +++ b/internal/db/sql/sessions.sql @@ -0,0 +1,43 @@ +-- sqlfluff:dialect:sqlite +-- name: CreateSession :one +INSERT INTO sessions ( + id, + title, + message_count, + tokens, + cost, + updated_at, + created_at +) VALUES ( + ?, + ?, + ?, + ?, + ?, + strftime('%s', 'now'), + strftime('%s', 'now') +) RETURNING *; + +-- name: GetSessionByID :one +SELECT * +FROM sessions +WHERE id = ? LIMIT 1; + +-- name: ListSessions :many +SELECT * +FROM sessions +ORDER BY created_at DESC; + +-- name: UpdateSession :one +UPDATE sessions +SET + title = ?, + tokens = ?, + cost = ? +WHERE id = ? +RETURNING *; + + +-- name: DeleteSession :exec +DELETE FROM sessions +WHERE id = ?; |
