// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.29.0 // source: frequencies.sql package data import ( "context" "github.com/kyren223/eko/pkg/snowflake" ) const createFrequency = `-- name: CreateFrequency :one INSERT INTO frequencies ( id, network_id, name, hex_color, perms, position ) VALUES ( ?1, ?2, ?3, ?4, ?5, (SELECT COUNT(*) FROM frequencies WHERE network_id = ?2) ) RETURNING id, network_id, name, hex_color, perms, position ` type CreateFrequencyParams struct { ID snowflake.ID NetworkID snowflake.ID Name string HexColor string Perms int64 } func (q *Queries) CreateFrequency(ctx context.Context, arg CreateFrequencyParams) (Frequency, error) { row := q.db.QueryRowContext(ctx, createFrequency, arg.ID, arg.NetworkID, arg.Name, arg.HexColor, arg.Perms, ) var i Frequency err := row.Scan( &i.ID, &i.NetworkID, &i.Name, &i.HexColor, &i.Perms, &i.Position, ) return i, err } const deleteFrequency = `-- name: DeleteFrequency :exec DELETE FROM frequencies WHERE id = ? ` func (q *Queries) DeleteFrequency(ctx context.Context, id snowflake.ID) error { _, err := q.db.ExecContext(ctx, deleteFrequency, id) return err } const getFrequencyById = `-- name: GetFrequencyById :one SELECT id, network_id, name, hex_color, perms, position FROM frequencies WHERE id = ? ` func (q *Queries) GetFrequencyById(ctx context.Context, id snowflake.ID) (Frequency, error) { row := q.db.QueryRowContext(ctx, getFrequencyById, id) var i Frequency err := row.Scan( &i.ID, &i.NetworkID, &i.Name, &i.HexColor, &i.Perms, &i.Position, ) return i, err } const getNetworkFrequencies = `-- name: GetNetworkFrequencies :many SELECT id, network_id, name, hex_color, perms, position FROM frequencies WHERE network_id = ? ORDER BY position ` func (q *Queries) GetNetworkFrequencies(ctx context.Context, networkID snowflake.ID) ([]Frequency, error) { rows, err := q.db.QueryContext(ctx, getNetworkFrequencies, networkID) if err != nil { return nil, err } defer rows.Close() var items []Frequency for rows.Next() { var i Frequency if err := rows.Scan( &i.ID, &i.NetworkID, &i.Name, &i.HexColor, &i.Perms, &i.Position, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const swapFrequencies = `-- name: SwapFrequencies :exec UPDATE frequencies SET position = CASE WHEN position = ?1 THEN ?2 WHEN position = ?2 THEN ?1 END WHERE network_id = ?3 AND position IN (?1, ?2) ` type SwapFrequenciesParams struct { Pos1 int64 Pos2 int64 NetworkID snowflake.ID } func (q *Queries) SwapFrequencies(ctx context.Context, arg SwapFrequenciesParams) error { _, err := q.db.ExecContext(ctx, swapFrequencies, arg.Pos1, arg.Pos2, arg.NetworkID) return err } const updateFrequency = `-- name: UpdateFrequency :one UPDATE frequencies SET name = ?, hex_color = ?, perms = ? WHERE id = ? RETURNING id, network_id, name, hex_color, perms, position ` type UpdateFrequencyParams struct { Name string HexColor string Perms int64 ID snowflake.ID } func (q *Queries) UpdateFrequency(ctx context.Context, arg UpdateFrequencyParams) (Frequency, error) { row := q.db.QueryRowContext(ctx, updateFrequency, arg.Name, arg.HexColor, arg.Perms, arg.ID, ) var i Frequency err := row.Scan( &i.ID, &i.NetworkID, &i.Name, &i.HexColor, &i.Perms, &i.Position, ) return i, err }