Enha: db chat management
This commit is contained in:
13
models/db.go
13
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user