2024-07-17 19:30:16 -04:00
|
|
|
// Code generated by sqlc. DO NOT EDIT.
|
|
|
|
// versions:
|
|
|
|
// sqlc v1.26.0
|
|
|
|
// source: talkgroups.sql
|
|
|
|
|
|
|
|
package database
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
)
|
|
|
|
|
|
|
|
const getTalkgroupTags = `-- name: GetTalkgroupTags :one
|
|
|
|
SELECT tags FROM talkgroups_tags
|
|
|
|
WHERE talkgroup_id = $1
|
|
|
|
`
|
|
|
|
|
2024-07-25 09:37:27 -04:00
|
|
|
func (q *Queries) GetTalkgroupTags(ctx context.Context, talkgroupID int) ([]string, error) {
|
2024-07-17 19:30:16 -04:00
|
|
|
row := q.db.QueryRow(ctx, getTalkgroupTags, talkgroupID)
|
|
|
|
var tags []string
|
|
|
|
err := row.Scan(&tags)
|
|
|
|
return tags, err
|
|
|
|
}
|
|
|
|
|
|
|
|
const getTalkgroupsWithAllTags = `-- name: GetTalkgroupsWithAllTags :many
|
2024-07-17 19:45:46 -04:00
|
|
|
SELECT system_id, talkgroup_id FROM talkgroups_tags
|
2024-07-17 19:30:16 -04:00
|
|
|
WHERE tags && ARRAY[$1]
|
|
|
|
`
|
|
|
|
|
2024-07-17 19:45:46 -04:00
|
|
|
type GetTalkgroupsWithAllTagsRow struct {
|
2024-07-25 09:37:27 -04:00
|
|
|
SystemID int `json:"system_id"`
|
|
|
|
TalkgroupID int `json:"talkgroup_id"`
|
2024-07-17 19:45:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) GetTalkgroupsWithAllTags(ctx context.Context, tags []string) ([]GetTalkgroupsWithAllTagsRow, error) {
|
2024-07-17 19:30:16 -04:00
|
|
|
rows, err := q.db.Query(ctx, getTalkgroupsWithAllTags, tags)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
2024-07-17 19:45:46 -04:00
|
|
|
var items []GetTalkgroupsWithAllTagsRow
|
2024-07-17 19:30:16 -04:00
|
|
|
for rows.Next() {
|
2024-07-17 19:45:46 -04:00
|
|
|
var i GetTalkgroupsWithAllTagsRow
|
|
|
|
if err := rows.Scan(&i.SystemID, &i.TalkgroupID); err != nil {
|
2024-07-17 19:30:16 -04:00
|
|
|
return nil, err
|
|
|
|
}
|
2024-07-17 19:45:46 -04:00
|
|
|
items = append(items, i)
|
2024-07-17 19:30:16 -04:00
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return items, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
const getTalkgroupsWithAnyTags = `-- name: GetTalkgroupsWithAnyTags :many
|
2024-07-17 19:45:46 -04:00
|
|
|
SELECT system_id, talkgroup_id FROM talkgroups_tags
|
2024-07-17 19:30:16 -04:00
|
|
|
WHERE tags @> ARRAY[$1]
|
|
|
|
`
|
|
|
|
|
2024-07-17 19:45:46 -04:00
|
|
|
type GetTalkgroupsWithAnyTagsRow struct {
|
2024-07-25 09:37:27 -04:00
|
|
|
SystemID int `json:"system_id"`
|
|
|
|
TalkgroupID int `json:"talkgroup_id"`
|
2024-07-17 19:45:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) GetTalkgroupsWithAnyTags(ctx context.Context, tags []string) ([]GetTalkgroupsWithAnyTagsRow, error) {
|
2024-07-17 19:30:16 -04:00
|
|
|
rows, err := q.db.Query(ctx, getTalkgroupsWithAnyTags, tags)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
2024-07-17 19:45:46 -04:00
|
|
|
var items []GetTalkgroupsWithAnyTagsRow
|
2024-07-17 19:30:16 -04:00
|
|
|
for rows.Next() {
|
2024-07-17 19:45:46 -04:00
|
|
|
var i GetTalkgroupsWithAnyTagsRow
|
|
|
|
if err := rows.Scan(&i.SystemID, &i.TalkgroupID); err != nil {
|
2024-07-17 19:30:16 -04:00
|
|
|
return nil, err
|
|
|
|
}
|
2024-07-17 19:45:46 -04:00
|
|
|
items = append(items, i)
|
2024-07-17 19:30:16 -04:00
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return items, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
const setTalkgroupTags = `-- name: SetTalkgroupTags :exec
|
2024-07-17 19:49:50 -04:00
|
|
|
INSERT INTO talkgroups_tags(system_id, talkgroup_id, tags) VALUES($1, $2, $3)
|
|
|
|
ON CONFLICT (system_id, talkgroup_id) DO UPDATE SET tags = $3
|
2024-07-17 19:30:16 -04:00
|
|
|
`
|
|
|
|
|
2024-07-25 09:37:27 -04:00
|
|
|
func (q *Queries) SetTalkgroupTags(ctx context.Context, systemID int, talkgroupID int, tags []string) error {
|
2024-07-22 08:39:33 -04:00
|
|
|
_, err := q.db.Exec(ctx, setTalkgroupTags, systemID, talkgroupID, tags)
|
2024-07-17 19:30:16 -04:00
|
|
|
return err
|
|
|
|
}
|