128 lines
2.2 KiB
Go
128 lines
2.2 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: user.sql
|
|
|
|
package sqlc
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const deleteUser = `-- name: DeleteUser :exec
|
|
DELETE FROM user
|
|
WHERE id = ?1
|
|
`
|
|
|
|
func (q *Queries) DeleteUser(ctx context.Context, id int64) error {
|
|
_, err := q.db.ExecContext(ctx, deleteUser, id)
|
|
return err
|
|
}
|
|
|
|
const getUser = `-- name: GetUser :one
|
|
SELECT
|
|
id,
|
|
username,
|
|
password,
|
|
profile_picture_id,
|
|
webauthn_id
|
|
FROM user
|
|
WHERE
|
|
id = ?1
|
|
LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetUser(ctx context.Context, id int64) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, getUser, id)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Username,
|
|
&i.Password,
|
|
&i.ProfilePictureID,
|
|
&i.WebauthnID,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUserbyUsername = `-- name: GetUserbyUsername :one
|
|
SELECT
|
|
id,
|
|
username,
|
|
password,
|
|
profile_picture_id,
|
|
webauthn_id
|
|
FROM user
|
|
WHERE
|
|
username = ?1
|
|
LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetUserbyUsername(ctx context.Context, username string) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, getUserbyUsername, username)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Username,
|
|
&i.Password,
|
|
&i.ProfilePictureID,
|
|
&i.WebauthnID,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const insertUser = `-- name: InsertUser :one
|
|
INSERT INTO user (
|
|
username,
|
|
password,
|
|
webauthn_id
|
|
) VALUES (
|
|
?1,
|
|
?2,
|
|
?3
|
|
)
|
|
RETURNING id
|
|
`
|
|
|
|
type InsertUserParams struct {
|
|
Username string
|
|
Password string
|
|
WebauthnID string
|
|
}
|
|
|
|
func (q *Queries) InsertUser(ctx context.Context, arg InsertUserParams) (int64, error) {
|
|
row := q.db.QueryRowContext(ctx, insertUser, arg.Username, arg.Password, arg.WebauthnID)
|
|
var id int64
|
|
err := row.Scan(&id)
|
|
return id, err
|
|
}
|
|
|
|
const updateUser = `-- name: UpdateUser :exec
|
|
UPDATE user
|
|
SET
|
|
username = COALESCE(?1, username),
|
|
password = COALESCE(?2, password),
|
|
profile_picture_id = COALESCE(
|
|
?3,
|
|
profile_picture_id
|
|
)
|
|
WHERE id = ?4
|
|
`
|
|
|
|
type UpdateUserParams struct {
|
|
Username *string
|
|
Password *string
|
|
ProfilePictureID *int64
|
|
ID int64
|
|
}
|
|
|
|
func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) error {
|
|
_, err := q.db.ExecContext(ctx, updateUser,
|
|
arg.Username,
|
|
arg.Password,
|
|
arg.ProfilePictureID,
|
|
arg.ID,
|
|
)
|
|
return err
|
|
}
|