53 lines
1.2 KiB
Go
53 lines
1.2 KiB
Go
|
|
// Code generated by sqlc. DO NOT EDIT.
|
||
|
|
// versions:
|
||
|
|
// sqlc v1.28.0
|
||
|
|
// source: users.sql
|
||
|
|
|
||
|
|
package sqlgen
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
)
|
||
|
|
|
||
|
|
const insertUser = `-- name: InsertUser :one
|
||
|
|
INSERT INTO users (username, password) VALUES (?, ?) RETURNING id
|
||
|
|
`
|
||
|
|
|
||
|
|
type InsertUserParams struct {
|
||
|
|
Username string
|
||
|
|
Password string
|
||
|
|
}
|
||
|
|
|
||
|
|
func (q *Queries) InsertUser(ctx context.Context, arg InsertUserParams) (int64, error) {
|
||
|
|
row := q.db.QueryRowContext(ctx, insertUser, arg.Username, arg.Password)
|
||
|
|
var id int64
|
||
|
|
err := row.Scan(&id)
|
||
|
|
return id, err
|
||
|
|
}
|
||
|
|
|
||
|
|
const selectUserByUsername = `-- name: SelectUserByUsername :one
|
||
|
|
SELECT id, username, password FROM users WHERE username = ?
|
||
|
|
`
|
||
|
|
|
||
|
|
func (q *Queries) SelectUserByUsername(ctx context.Context, username string) (User, error) {
|
||
|
|
row := q.db.QueryRowContext(ctx, selectUserByUsername, username)
|
||
|
|
var i User
|
||
|
|
err := row.Scan(&i.ID, &i.Username, &i.Password)
|
||
|
|
return i, err
|
||
|
|
}
|
||
|
|
|
||
|
|
const updateUser = `-- name: UpdateUser :exec
|
||
|
|
UPDATE users SET username = ?, password = ? WHERE id = ?
|
||
|
|
`
|
||
|
|
|
||
|
|
type UpdateUserParams struct {
|
||
|
|
Username string
|
||
|
|
Password string
|
||
|
|
ID int64
|
||
|
|
}
|
||
|
|
|
||
|
|
func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) error {
|
||
|
|
_, err := q.db.ExecContext(ctx, updateUser, arg.Username, arg.Password, arg.ID)
|
||
|
|
return err
|
||
|
|
}
|