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.
 
 

30 lines
1.1 KiB

-- name: SelectChannelByName :one
SELECT * FROM data_channel WHERE name = $1 LIMIT 1;
-- name: InsertChannel :exec
INSERT INTO data_channel (name, logged, hub, event_name, location_name)
VALUES (
sqlc.arg(name)::text,
sqlc.arg(logged)::boolean, sqlc.arg(hub)::boolean,
sqlc.arg(event_name)::text, sqlc.arg(location_name)::text
);
-- name: SelectChannels :many
SELECT * FROM data_channel
WHERE (sqlc.arg(filter_name)::bool = false OR name = ANY(sqlc.arg(names)::text[]))
AND (sqlc.arg(filter_logged)::bool = false OR logged = sqlc.arg(logged))
AND (sqlc.arg(filter_event_name)::bool = false OR event_name = sqlc.arg(event_name))
AND (sqlc.arg(filter_location_name)::bool = false OR location_name = sqlc.arg(location_name))
ORDER BY name
LIMIT sqlc.arg(limit_size)::int;
-- name: UpdateChannel :exec
UPDATE data_channel
SET logged=sqlc.arg(logged)::boolean,
hub=sqlc.arg(hub)::boolean,
event_name=sqlc.arg(event_name)::text,
location_name=sqlc.arg(location_name)::text
WHERE name=sqlc.arg(name)::text;
-- name: DeleteChannel :exec
DELETE FROM data_channel WHERE name=$1;