summaryrefslogtreecommitdiffhomepage
path: root/internal/db/sql
diff options
context:
space:
mode:
authorKujtim Hoxha <[email protected]>2025-03-23 19:19:08 +0100
committerKujtim Hoxha <[email protected]>2025-03-23 19:19:08 +0100
commit8daa6e774a6e02698c90392e7b2008542f789594 (patch)
tree8053fc1a4de87fc8dc3fd6e776577b0221c02ac5 /internal/db/sql
parent796bbf4d66c0fc70e750c7f582019cb9a7298e59 (diff)
downloadopencode-8daa6e774a6e02698c90392e7b2008542f789594.tar.gz
opencode-8daa6e774a6e02698c90392e7b2008542f789594.zip
add initial stuff
Diffstat (limited to 'internal/db/sql')
-rw-r--r--internal/db/sql/sessions.sql43
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 = ?;