summaryrefslogtreecommitdiff
path: root/storage/storage.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2024-11-24 17:39:52 +0300
committerGrail Finder <wohilas@gmail.com>2024-11-24 17:39:52 +0300
commit5dfb5584767e56180771ca08c4c27def3b2db536 (patch)
tree388ce3205db9f1bb615da305926574bdfe58437b /storage/storage.go
parent6625a8103bb70833e2399567cbbe7f3b4a8da429 (diff)
Feat: rename chatHEADmaster
Diffstat (limited to 'storage/storage.go')
-rw-r--r--storage/storage.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/storage/storage.go b/storage/storage.go
index 08cd81a..c863799 100644
--- a/storage/storage.go
+++ b/storage/storage.go
@@ -19,6 +19,7 @@ type ChatHistory interface {
GetLastChat() (*models.Chat, error)
UpsertChat(chat *models.Chat) (*models.Chat, error)
RemoveChat(id uint32) error
+ ChatGetMaxID() (uint32, error)
}
type ProviderSQL struct {
@@ -66,6 +67,13 @@ func (p ProviderSQL) RemoveChat(id uint32) error {
return err
}
+func (p ProviderSQL) ChatGetMaxID() (uint32, error) {
+ query := "SELECT MAX(id) FROM chats;"
+ var id uint32
+ err := p.db.Get(&id, query)
+ return id, err
+}
+
func NewProviderSQL(dbPath string, logger *slog.Logger) FullRepo {
db, err := sqlx.Open("sqlite", dbPath)
if err != nil {