mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
68 lines
1.5 KiB
Go
68 lines
1.5 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: events.sql
|
|
|
|
package sqlc
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const insertLifecycleEvent = `-- name: InsertLifecycleEvent :exec
|
|
INSERT INTO lifecycle_events (id, container_id, event_type, payload)
|
|
VALUES (
|
|
$1,
|
|
$2,
|
|
$3,
|
|
$4
|
|
)
|
|
`
|
|
|
|
type InsertLifecycleEventParams struct {
|
|
ID string `json:"id"`
|
|
ContainerID string `json:"container_id"`
|
|
EventType string `json:"event_type"`
|
|
Payload []byte `json:"payload"`
|
|
}
|
|
|
|
func (q *Queries) InsertLifecycleEvent(ctx context.Context, arg InsertLifecycleEventParams) error {
|
|
_, err := q.db.Exec(ctx, insertLifecycleEvent,
|
|
arg.ID,
|
|
arg.ContainerID,
|
|
arg.EventType,
|
|
arg.Payload,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const listLifecycleEventsByContainerID = `-- name: ListLifecycleEventsByContainerID :many
|
|
SELECT id, container_id, event_type, payload, created_at FROM lifecycle_events WHERE container_id = $1 ORDER BY created_at ASC
|
|
`
|
|
|
|
func (q *Queries) ListLifecycleEventsByContainerID(ctx context.Context, containerID string) ([]LifecycleEvent, error) {
|
|
rows, err := q.db.Query(ctx, listLifecycleEventsByContainerID, containerID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []LifecycleEvent
|
|
for rows.Next() {
|
|
var i LifecycleEvent
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.ContainerID,
|
|
&i.EventType,
|
|
&i.Payload,
|
|
&i.CreatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|