diff options
| author | Kyren223 <Kyren223@proton.me> | 2025-01-14 16:31:32 +0200 |
|---|---|---|
| committer | Kyren223 <Kyren223@proton.me> | 2025-01-14 16:31:32 +0200 |
| commit | 8184c8d18799feb7ef0aa0eed7e5a2e67a01c791 (patch) | |
| tree | 45a0174ed90b11c6ce89db06ee7237e6ae4dad20 /internal/data/networks.sql.go | |
| parent | fa2ba2fe8bf24cc9ddc28ec30ea64647d17af1d6 (diff) | |
Added a way to change network properties both server side and client
side
Diffstat (limited to 'internal/data/networks.sql.go')
| -rw-r--r-- | internal/data/networks.sql.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/internal/data/networks.sql.go b/internal/data/networks.sql.go index 5091602..af3c273 100644 --- a/internal/data/networks.sql.go +++ b/internal/data/networks.sql.go @@ -110,3 +110,43 @@ func (q *Queries) TransferNetwork(ctx context.Context, arg TransferNetworkParams ) return i, err } + +const updateNetwork = `-- name: UpdateNetwork :one +UPDATE networks SET + name = ?, icon = ?, + bg_hex_color = ?, fg_hex_color = ?, + is_public = ? +WHERE id = ? +RETURNING id, owner_id, name, icon, bg_hex_color, fg_hex_color, is_public +` + +type UpdateNetworkParams struct { + Name string + Icon string + BgHexColor string + FgHexColor string + IsPublic bool + ID snowflake.ID +} + +func (q *Queries) UpdateNetwork(ctx context.Context, arg UpdateNetworkParams) (Network, error) { + row := q.db.QueryRowContext(ctx, updateNetwork, + arg.Name, + arg.Icon, + arg.BgHexColor, + arg.FgHexColor, + arg.IsPublic, + arg.ID, + ) + var i Network + err := row.Scan( + &i.ID, + &i.OwnerID, + &i.Name, + &i.Icon, + &i.BgHexColor, + &i.FgHexColor, + &i.IsPublic, + ) + return i, err +} |
