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
|
2024-07-28 23:07:04 -04:00
|
|
|
SELECT tags FROM talkgroups
|
|
|
|
WHERE system_id = $1 AND tgid = $2
|
2024-07-17 19:30:16 -04:00
|
|
|
`
|
|
|
|
|
2024-07-28 23:07:04 -04:00
|
|
|
func (q *Queries) GetTalkgroupTags(ctx context.Context, systemID int, tgid int) ([]string, error) {
|
|
|
|
row := q.db.QueryRow(ctx, getTalkgroupTags, systemID, tgid)
|
2024-07-17 19:30:16 -04:00
|
|
|
var tags []string
|
|
|
|
err := row.Scan(&tags)
|
|
|
|
return tags, err
|
|
|
|
}
|
|
|
|
|
|
|
|
const getTalkgroupsWithAllTags = `-- name: GetTalkgroupsWithAllTags :many
|
2024-07-28 23:07:04 -04:00
|
|
|
SELECT system_id, tgid, name, tg_group, frequency, metadata, tags FROM talkgroups
|
2024-07-17 19:30:16 -04:00
|
|
|
WHERE tags && ARRAY[$1]
|
|
|
|
`
|
|
|
|
|
2024-07-28 23:07:04 -04:00
|
|
|
func (q *Queries) GetTalkgroupsWithAllTags(ctx context.Context, tags []string) ([]Talkgroup, 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-28 23:07:04 -04:00
|
|
|
var items []Talkgroup
|
2024-07-17 19:30:16 -04:00
|
|
|
for rows.Next() {
|
2024-07-28 23:07:04 -04:00
|
|
|
var i Talkgroup
|
|
|
|
if err := rows.Scan(
|
|
|
|
&i.SystemID,
|
|
|
|
&i.Tgid,
|
|
|
|
&i.Name,
|
|
|
|
&i.TgGroup,
|
|
|
|
&i.Frequency,
|
|
|
|
&i.Metadata,
|
|
|
|
&i.Tags,
|
|
|
|
); 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-28 23:07:04 -04:00
|
|
|
SELECT system_id, tgid, name, tg_group, frequency, metadata, tags FROM talkgroups
|
2024-07-17 19:30:16 -04:00
|
|
|
WHERE tags @> ARRAY[$1]
|
|
|
|
`
|
|
|
|
|
2024-07-28 23:07:04 -04:00
|
|
|
func (q *Queries) GetTalkgroupsWithAnyTags(ctx context.Context, tags []string) ([]Talkgroup, 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-28 23:07:04 -04:00
|
|
|
var items []Talkgroup
|
2024-07-17 19:30:16 -04:00
|
|
|
for rows.Next() {
|
2024-07-28 23:07:04 -04:00
|
|
|
var i Talkgroup
|
|
|
|
if err := rows.Scan(
|
|
|
|
&i.SystemID,
|
|
|
|
&i.Tgid,
|
|
|
|
&i.Name,
|
|
|
|
&i.TgGroup,
|
|
|
|
&i.Frequency,
|
|
|
|
&i.Metadata,
|
|
|
|
&i.Tags,
|
|
|
|
); 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-28 23:07:04 -04:00
|
|
|
UPDATE talkgroups SET tags = $1
|
|
|
|
WHERE system_id = $1 AND tgid = $2
|
2024-07-17 19:30:16 -04:00
|
|
|
`
|
|
|
|
|
2024-07-28 23:07:04 -04:00
|
|
|
func (q *Queries) SetTalkgroupTags(ctx context.Context, tags []string, tgid int) error {
|
|
|
|
_, err := q.db.Exec(ctx, setTalkgroupTags, tags, tgid)
|
2024-07-17 19:30:16 -04:00
|
|
|
return err
|
|
|
|
}
|