diff options
author | Grail Finder <wohilas@gmail.com> | 2024-11-20 06:51:40 +0300 |
---|---|---|
committer | Grail Finder <wohilas@gmail.com> | 2024-11-20 06:51:40 +0300 |
commit | aaf056663628f15bb6e4f23c899b6fd31bac5bf7 (patch) | |
tree | a0129fbb531e31d1a9d6465549a44b823906aaae /models | |
parent | f32375488f5127c910021f627d83e017c5c7a10f (diff) |
Enha: db chat management
Diffstat (limited to 'models')
-rw-r--r-- | models/db.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/models/db.go b/models/db.go index 24bef41..afd4b46 100644 --- a/models/db.go +++ b/models/db.go @@ -1,6 +1,9 @@ package models -import "time" +import ( + "encoding/json" + "time" +) type Chat struct { ID uint32 `db:"id" json:"id"` @@ -9,3 +12,11 @@ type Chat struct { CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` } + +func (c Chat) ToHistory() ([]MessagesStory, error) { + resp := []MessagesStory{} + if err := json.Unmarshal([]byte(c.Msgs), &resp); err != nil { + return nil, err + } + return resp, nil +} |