stillbox/sql/postgres/queries/talkgroups.sql
2024-07-17 19:49:50 -04:00

16 lines
500 B
SQL

-- name: GetTalkgroupsWithAnyTags :many
SELECT system_id, talkgroup_id FROM talkgroups_tags
WHERE tags @> ARRAY[$1];
-- name: GetTalkgroupsWithAllTags :many
SELECT system_id, talkgroup_id FROM talkgroups_tags
WHERE tags && ARRAY[$1];
-- name: GetTalkgroupTags :one
SELECT tags FROM talkgroups_tags
WHERE talkgroup_id = $1;
-- name: SetTalkgroupTags :exec
INSERT INTO talkgroups_tags(system_id, talkgroup_id, tags) VALUES($1, $2, $3)
ON CONFLICT (system_id, talkgroup_id) DO UPDATE SET tags = $3;