GraphQL API and utilities for the rpdata project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

152 lines
3.6 KiB

// Code generated by sqlc. DO NOT EDIT.
// source: channels.sql
package psqlcore
import (
"context"
"github.com/lib/pq"
)
const deleteChannel = `-- name: DeleteChannel :exec
DELETE FROM data_channel WHERE name=$1
`
func (q *Queries) DeleteChannel(ctx context.Context, name string) error {
_, err := q.db.ExecContext(ctx, deleteChannel, name)
return err
}
const insertChannel = `-- name: InsertChannel :exec
INSERT INTO data_channel (name, logged, hub, event_name, location_name)
VALUES (
$1::text,
$2::boolean, $3::boolean,
$4::text, $5::text
)
`
type InsertChannelParams struct {
Name string `json:"name"`
Logged bool `json:"logged"`
Hub bool `json:"hub"`
EventName string `json:"event_name"`
LocationName string `json:"location_name"`
}
func (q *Queries) InsertChannel(ctx context.Context, arg InsertChannelParams) error {
_, err := q.db.ExecContext(ctx, insertChannel,
arg.Name,
arg.Logged,
arg.Hub,
arg.EventName,
arg.LocationName,
)
return err
}
const selectChannelByName = `-- name: SelectChannelByName :one
SELECT name, logged, hub, event_name, location_name FROM data_channel WHERE name = $1 LIMIT 1
`
func (q *Queries) SelectChannelByName(ctx context.Context, name string) (DataChannel, error) {
row := q.db.QueryRowContext(ctx, selectChannelByName, name)
var i DataChannel
err := row.Scan(
&i.Name,
&i.Logged,
&i.Hub,
&i.EventName,
&i.LocationName,
)
return i, err
}
const selectChannels = `-- name: SelectChannels :many
SELECT name, logged, hub, event_name, location_name FROM data_channel
WHERE ($1::bool = false OR name = ANY($2::text[]))
AND ($3::bool = false OR logged = $4)
AND ($5::bool = false OR event_name = $6)
AND ($7::bool = false OR location_name = $8)
LIMIT $9::int
`
type SelectChannelsParams struct {
FilterName bool `json:"filter_name"`
Names []string `json:"names"`
FilterLogged bool `json:"filter_logged"`
Logged bool `json:"logged"`
FilterEventName bool `json:"filter_event_name"`
EventName string `json:"event_name"`
FilterLocationName bool `json:"filter_location_name"`
LocationName string `json:"location_name"`
LimitSize int32 `json:"limit_size"`
}
func (q *Queries) SelectChannels(ctx context.Context, arg SelectChannelsParams) ([]DataChannel, error) {
rows, err := q.db.QueryContext(ctx, selectChannels,
arg.FilterName,
pq.Array(arg.Names),
arg.FilterLogged,
arg.Logged,
arg.FilterEventName,
arg.EventName,
arg.FilterLocationName,
arg.LocationName,
arg.LimitSize,
)
if err != nil {
return nil, err
}
defer rows.Close()
items := []DataChannel{}
for rows.Next() {
var i DataChannel
if err := rows.Scan(
&i.Name,
&i.Logged,
&i.Hub,
&i.EventName,
&i.LocationName,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const updateChannel = `-- name: UpdateChannel :exec
UPDATE data_channel
SET logged=$1::boolean,
hub=$2::boolean,
event_name=$3::text,
location_name=$4::text
WHERE name=$5::text
`
type UpdateChannelParams struct {
Logged bool `json:"logged"`
Hub bool `json:"hub"`
EventName string `json:"event_name"`
LocationName string `json:"location_name"`
Name string `json:"name"`
}
func (q *Queries) UpdateChannel(ctx context.Context, arg UpdateChannelParams) error {
_, err := q.db.ExecContext(ctx, updateChannel,
arg.Logged,
arg.Hub,
arg.EventName,
arg.LocationName,
arg.Name,
)
return err
}