// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.30.0 // source: channels.sql package db import ( "context" "github.com/jackc/pgx/v5/pgtype" ) const deleteAllChannelsByTeam = `-- name: DeleteAllChannelsByTeam :exec DELETE FROM channels WHERE team_id = $1 ` func (q *Queries) DeleteAllChannelsByTeam(ctx context.Context, teamID pgtype.UUID) error { _, err := q.db.Exec(ctx, deleteAllChannelsByTeam, teamID) return err } const deleteChannelByTeam = `-- name: DeleteChannelByTeam :exec DELETE FROM channels WHERE id = $1 AND team_id = $2 ` type DeleteChannelByTeamParams struct { ID pgtype.UUID `json:"id"` TeamID pgtype.UUID `json:"team_id"` } func (q *Queries) DeleteChannelByTeam(ctx context.Context, arg DeleteChannelByTeamParams) error { _, err := q.db.Exec(ctx, deleteChannelByTeam, arg.ID, arg.TeamID) return err } const getChannelByTeam = `-- name: GetChannelByTeam :one SELECT id, team_id, name, provider, config, event_types, created_at, updated_at FROM channels WHERE id = $1 AND team_id = $2 ` type GetChannelByTeamParams struct { ID pgtype.UUID `json:"id"` TeamID pgtype.UUID `json:"team_id"` } func (q *Queries) GetChannelByTeam(ctx context.Context, arg GetChannelByTeamParams) (Channel, error) { row := q.db.QueryRow(ctx, getChannelByTeam, arg.ID, arg.TeamID) var i Channel err := row.Scan( &i.ID, &i.TeamID, &i.Name, &i.Provider, &i.Config, &i.EventTypes, &i.CreatedAt, &i.UpdatedAt, ) return i, err } const insertChannel = `-- name: InsertChannel :one INSERT INTO channels (id, team_id, name, provider, config, event_types) VALUES ($1, $2, $3, $4, $5, $6) RETURNING id, team_id, name, provider, config, event_types, created_at, updated_at ` type InsertChannelParams struct { ID pgtype.UUID `json:"id"` TeamID pgtype.UUID `json:"team_id"` Name string `json:"name"` Provider string `json:"provider"` Config []byte `json:"config"` EventTypes []string `json:"event_types"` } func (q *Queries) InsertChannel(ctx context.Context, arg InsertChannelParams) (Channel, error) { row := q.db.QueryRow(ctx, insertChannel, arg.ID, arg.TeamID, arg.Name, arg.Provider, arg.Config, arg.EventTypes, ) var i Channel err := row.Scan( &i.ID, &i.TeamID, &i.Name, &i.Provider, &i.Config, &i.EventTypes, &i.CreatedAt, &i.UpdatedAt, ) return i, err } const listChannelsByTeam = `-- name: ListChannelsByTeam :many SELECT id, team_id, name, provider, config, event_types, created_at, updated_at FROM channels WHERE team_id = $1 ORDER BY created_at DESC ` func (q *Queries) ListChannelsByTeam(ctx context.Context, teamID pgtype.UUID) ([]Channel, error) { rows, err := q.db.Query(ctx, listChannelsByTeam, teamID) if err != nil { return nil, err } defer rows.Close() var items []Channel for rows.Next() { var i Channel if err := rows.Scan( &i.ID, &i.TeamID, &i.Name, &i.Provider, &i.Config, &i.EventTypes, &i.CreatedAt, &i.UpdatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const listChannelsForEvent = `-- name: ListChannelsForEvent :many SELECT id, team_id, name, provider, config, event_types, created_at, updated_at FROM channels WHERE team_id = $1 AND $2::text = ANY(event_types) ORDER BY created_at ` type ListChannelsForEventParams struct { TeamID pgtype.UUID `json:"team_id"` EventType string `json:"event_type"` } func (q *Queries) ListChannelsForEvent(ctx context.Context, arg ListChannelsForEventParams) ([]Channel, error) { rows, err := q.db.Query(ctx, listChannelsForEvent, arg.TeamID, arg.EventType) if err != nil { return nil, err } defer rows.Close() var items []Channel for rows.Next() { var i Channel if err := rows.Scan( &i.ID, &i.TeamID, &i.Name, &i.Provider, &i.Config, &i.EventTypes, &i.CreatedAt, &i.UpdatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const updateChannel = `-- name: UpdateChannel :one UPDATE channels SET name = $3, event_types = $4, updated_at = NOW() WHERE id = $1 AND team_id = $2 RETURNING id, team_id, name, provider, config, event_types, created_at, updated_at ` type UpdateChannelParams struct { ID pgtype.UUID `json:"id"` TeamID pgtype.UUID `json:"team_id"` Name string `json:"name"` EventTypes []string `json:"event_types"` } func (q *Queries) UpdateChannel(ctx context.Context, arg UpdateChannelParams) (Channel, error) { row := q.db.QueryRow(ctx, updateChannel, arg.ID, arg.TeamID, arg.Name, arg.EventTypes, ) var i Channel err := row.Scan( &i.ID, &i.TeamID, &i.Name, &i.Provider, &i.Config, &i.EventTypes, &i.CreatedAt, &i.UpdatedAt, ) return i, err } const updateChannelConfig = `-- name: UpdateChannelConfig :one UPDATE channels SET config = $3, updated_at = NOW() WHERE id = $1 AND team_id = $2 RETURNING id, team_id, name, provider, config, event_types, created_at, updated_at ` type UpdateChannelConfigParams struct { ID pgtype.UUID `json:"id"` TeamID pgtype.UUID `json:"team_id"` Config []byte `json:"config"` } func (q *Queries) UpdateChannelConfig(ctx context.Context, arg UpdateChannelConfigParams) (Channel, error) { row := q.db.QueryRow(ctx, updateChannelConfig, arg.ID, arg.TeamID, arg.Config) var i Channel err := row.Scan( &i.ID, &i.TeamID, &i.Name, &i.Provider, &i.Config, &i.EventTypes, &i.CreatedAt, &i.UpdatedAt, ) return i, err }