mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
feat: chat api
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.30.0
|
||||
// source: history.sql
|
||||
|
||||
package sqlc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const createHistory = `-- name: CreateHistory :one
|
||||
INSERT INTO history (messages, timestamp, "user")
|
||||
VALUES ($1, $2, $3)
|
||||
RETURNING id, messages, timestamp, "user"
|
||||
`
|
||||
|
||||
type CreateHistoryParams struct {
|
||||
Messages []byte `json:"messages"`
|
||||
Timestamp pgtype.Timestamptz `json:"timestamp"`
|
||||
User pgtype.UUID `json:"user"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateHistory(ctx context.Context, arg CreateHistoryParams) (History, error) {
|
||||
row := q.db.QueryRow(ctx, createHistory, arg.Messages, arg.Timestamp, arg.User)
|
||||
var i History
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Messages,
|
||||
&i.Timestamp,
|
||||
&i.User,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listHistoryByUserSince = `-- name: ListHistoryByUserSince :many
|
||||
SELECT id, messages, timestamp, "user"
|
||||
FROM history
|
||||
WHERE "user" = $1 AND timestamp >= $2
|
||||
ORDER BY timestamp ASC
|
||||
`
|
||||
|
||||
type ListHistoryByUserSinceParams struct {
|
||||
User pgtype.UUID `json:"user"`
|
||||
Timestamp pgtype.Timestamptz `json:"timestamp"`
|
||||
}
|
||||
|
||||
func (q *Queries) ListHistoryByUserSince(ctx context.Context, arg ListHistoryByUserSinceParams) ([]History, error) {
|
||||
rows, err := q.db.Query(ctx, listHistoryByUserSince, arg.User, arg.Timestamp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []History
|
||||
for rows.Next() {
|
||||
var i History
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Messages,
|
||||
&i.Timestamp,
|
||||
&i.User,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
@@ -33,6 +33,13 @@ type ContainerVersion struct {
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
}
|
||||
|
||||
type History struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
Messages []byte `json:"messages"`
|
||||
Timestamp pgtype.Timestamptz `json:"timestamp"`
|
||||
User pgtype.UUID `json:"user"`
|
||||
}
|
||||
|
||||
type LifecycleEvent struct {
|
||||
ID string `json:"id"`
|
||||
ContainerID string `json:"container_id"`
|
||||
|
||||
Reference in New Issue
Block a user