From 43bd630ecb9470b997c9f8fa47aa6960ac551faa Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Tue, 14 Jan 2025 17:33:15 +0200 Subject: Implemented updating frequency properties both client-side and server-side --- internal/data/frequencies.sql.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'internal/data') diff --git a/internal/data/frequencies.sql.go b/internal/data/frequencies.sql.go index 9ee8994..171943f 100644 --- a/internal/data/frequencies.sql.go +++ b/internal/data/frequencies.sql.go @@ -134,3 +134,36 @@ func (q *Queries) SwapFrequencies(ctx context.Context, arg SwapFrequenciesParams _, 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 +} -- cgit v1.3.1