diff options
| author | Kyren223 <Kyren223@proton.me> | 2024-11-23 18:47:26 +0200 |
|---|---|---|
| committer | Kyren223 <Kyren223@proton.me> | 2024-11-23 18:47:26 +0200 |
| commit | 77d9971982e336aa6c0b816d84f2d37780c02de6 (patch) | |
| tree | 0001051202a93b5b994d3fd5470e5bfc35a67af5 /internal/data/users.sql.go | |
| parent | 63a1d24295122728820a61aa93b3da6cd6d401d9 (diff) | |
Added network queries
Diffstat (limited to 'internal/data/users.sql.go')
| -rw-r--r-- | internal/data/users.sql.go | 66 |
1 files changed, 14 insertions, 52 deletions
diff --git a/internal/data/users.sql.go b/internal/data/users.sql.go index 7d2e065..9728c21 100644 --- a/internal/data/users.sql.go +++ b/internal/data/users.sql.go @@ -119,32 +119,6 @@ func (q *Queries) GetUserByPublicKey(ctx context.Context, publicKey ed25519.Publ return i, err } -const serUserPublicDMs = `-- name: SerUserPublicDMs :one -UPDATE users SET - is_public_dm = ? -WHERE id = ? AND is_deleted = false -RETURNING id, name, public_key, description, is_public_dm, is_deleted -` - -type SerUserPublicDMsParams struct { - IsPublicDm bool - ID snowflake.ID -} - -func (q *Queries) SerUserPublicDMs(ctx context.Context, arg SerUserPublicDMsParams) (User, error) { - row := q.db.QueryRowContext(ctx, serUserPublicDMs, arg.IsPublicDm, arg.ID) - var i User - err := row.Scan( - &i.ID, - &i.Name, - &i.PublicKey, - &i.Description, - &i.IsPublicDm, - &i.IsDeleted, - ) - return i, err -} - const setUserDescription = `-- name: SetUserDescription :one UPDATE users SET description = ? @@ -197,20 +171,20 @@ func (q *Queries) SetUserName(ctx context.Context, arg SetUserNameParams) (User, return i, err } -const setUserPublicKey = `-- name: SetUserPublicKey :one +const setUserPublicDMs = `-- name: SetUserPublicDMs :one UPDATE users SET - public_key = ? + is_public_dm = ? WHERE id = ? AND is_deleted = false RETURNING id, name, public_key, description, is_public_dm, is_deleted ` -type SetUserPublicKeyParams struct { - PublicKey ed25519.PublicKey - ID snowflake.ID +type SetUserPublicDMsParams struct { + IsPublicDm bool + ID snowflake.ID } -func (q *Queries) SetUserPublicKey(ctx context.Context, arg SetUserPublicKeyParams) (User, error) { - row := q.db.QueryRowContext(ctx, setUserPublicKey, arg.PublicKey, arg.ID) +func (q *Queries) SetUserPublicDMs(ctx context.Context, arg SetUserPublicDMsParams) (User, error) { + row := q.db.QueryRowContext(ctx, setUserPublicDMs, arg.IsPublicDm, arg.ID) var i User err := row.Scan( &i.ID, @@ -223,32 +197,20 @@ func (q *Queries) SetUserPublicKey(ctx context.Context, arg SetUserPublicKeyPara return i, err } -const updateUser = `-- name: UpdateUser :one +const setUserPublicKey = `-- name: SetUserPublicKey :one UPDATE users SET - name = COALESCE(?, name), - public_key = COALESCE(?, public_key), - description = COALESCE(?, description), - is_public_dm = COALESCE(?, is_public_dm) + public_key = ? WHERE id = ? AND is_deleted = false RETURNING id, name, public_key, description, is_public_dm, is_deleted ` -type UpdateUserParams struct { - Name string - PublicKey ed25519.PublicKey - Description *string - IsPublicDm bool - ID snowflake.ID +type SetUserPublicKeyParams struct { + PublicKey ed25519.PublicKey + ID snowflake.ID } -func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error) { - row := q.db.QueryRowContext(ctx, updateUser, - arg.Name, - arg.PublicKey, - arg.Description, - arg.IsPublicDm, - arg.ID, - ) +func (q *Queries) SetUserPublicKey(ctx context.Context, arg SetUserPublicKeyParams) (User, error) { + row := q.db.QueryRowContext(ctx, setUserPublicKey, arg.PublicKey, arg.ID) var i User err := row.Scan( &i.ID, |
