// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.27.0 // source: share.sql package database import ( "context" "github.com/google/uuid" "github.com/jackc/pgx/v5/pgtype" ) const createShare = `-- name: CreateShare :exec INSERT INTO shares ( id, entity_type, entity_id, entity_date, owner, expiration ) VALUES ($1, $2, $3, $4, $5, $6) ` type CreateShareParams struct { ID string `json:"id"` EntityType string `json:"entity_type"` EntityID uuid.UUID `json:"entity_id"` EntityDate pgtype.Timestamptz `json:"entity_date"` Owner int `json:"owner"` Expiration pgtype.Timestamptz `json:"expiration"` } func (q *Queries) CreateShare(ctx context.Context, arg CreateShareParams) error { _, err := q.db.Exec(ctx, createShare, arg.ID, arg.EntityType, arg.EntityID, arg.EntityDate, arg.Owner, arg.Expiration, ) return err } const deleteShare = `-- name: DeleteShare :exec DELETE FROM shares WHERE id = $1 ` func (q *Queries) DeleteShare(ctx context.Context, id string) error { _, err := q.db.Exec(ctx, deleteShare, id) return err } const getIncidentTalkgroups = `-- name: GetIncidentTalkgroups :many SELECT DISTINCT c.system, c.talkgroup FROM incidents_calls ic JOIN calls c ON (c.id = ic.call_id AND c.call_date = ic.call_date) WHERE ic.incident_id = $1 ` type GetIncidentTalkgroupsRow struct { System int `json:"system"` Talkgroup int `json:"talkgroup"` } func (q *Queries) GetIncidentTalkgroups(ctx context.Context, incidentID uuid.UUID) ([]GetIncidentTalkgroupsRow, error) { rows, err := q.db.Query(ctx, getIncidentTalkgroups, incidentID) if err != nil { return nil, err } defer rows.Close() var items []GetIncidentTalkgroupsRow for rows.Next() { var i GetIncidentTalkgroupsRow if err := rows.Scan(&i.System, &i.Talkgroup); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const getShare = `-- name: GetShare :one SELECT id, entity_type, entity_id, entity_date, owner, expiration FROM shares WHERE id = $1 ` func (q *Queries) GetShare(ctx context.Context, id string) (Share, error) { row := q.db.QueryRow(ctx, getShare, id) var i Share err := row.Scan( &i.ID, &i.EntityType, &i.EntityID, &i.EntityDate, &i.Owner, &i.Expiration, ) return i, err } const pruneShares = `-- name: PruneShares :exec DELETE FROM shares WHERE expiration < NOW() ` func (q *Queries) PruneShares(ctx context.Context) error { _, err := q.db.Exec(ctx, pruneShares) return err }