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

  1. -- name: SelectChannelByName :one
  2. SELECT * FROM data_channel WHERE name = $1 LIMIT 1;
  3. -- name: InsertChannel :exec
  4. INSERT INTO data_channel (name, logged, hub, event_name, location_name)
  5. VALUES (
  6. sqlc.arg(name)::text,
  7. sqlc.arg(logged)::boolean, sqlc.arg(hub)::boolean,
  8. sqlc.arg(event_name)::text, sqlc.arg(location_name)::text
  9. );
  10. -- name: SelectChannels :many
  11. SELECT * FROM data_channel
  12. WHERE (sqlc.arg(filter_name)::bool = false OR name = ANY(sqlc.arg(names)::text[]))
  13. AND (sqlc.arg(filter_logged)::bool = false OR logged = sqlc.arg(logged))
  14. AND (sqlc.arg(filter_event_name)::bool = false OR event_name = sqlc.arg(event_name))
  15. AND (sqlc.arg(filter_location_name)::bool = false OR location_name = sqlc.arg(location_name))
  16. ORDER BY name
  17. LIMIT sqlc.arg(limit_size)::int;
  18. -- name: UpdateChannel :exec
  19. UPDATE data_channel
  20. SET logged=sqlc.arg(logged)::boolean,
  21. hub=sqlc.arg(hub)::boolean,
  22. event_name=sqlc.arg(event_name)::text,
  23. location_name=sqlc.arg(location_name)::text
  24. WHERE name=sqlc.arg(name)::text;
  25. -- name: DeleteChannel :exec
  26. DELETE FROM data_channel WHERE name=$1;