weiro/providers/db/gen/sqlgen/users.sql.go

75 lines
1.7 KiB
Go
Raw Normal View History

2026-02-19 11:29:44 +00:00
// Code generated by sqlc. DO NOT EDIT.
// versions:
2026-02-20 06:39:58 +00:00
// sqlc v1.30.0
2026-02-19 11:29:44 +00:00
// source: users.sql
package sqlgen
import (
"context"
)
const insertUser = `-- name: InsertUser :one
INSERT INTO users (username, password, created_at) VALUES (?, ?, ?) RETURNING id
2026-02-19 11:29:44 +00:00
`
type InsertUserParams struct {
Username string
Password string
CreatedAt int64
2026-02-19 11:29:44 +00:00
}
func (q *Queries) InsertUser(ctx context.Context, arg InsertUserParams) (int64, error) {
row := q.db.QueryRowContext(ctx, insertUser, arg.Username, arg.Password, arg.CreatedAt)
2026-02-19 11:29:44 +00:00
var id int64
err := row.Scan(&id)
return id, err
}
2026-02-25 11:04:47 +00:00
const selectUserByID = `-- name: SelectUserByID :one
SELECT id, username, password, created_at FROM users WHERE id = ? LIMIT 1
2026-02-25 11:04:47 +00:00
`
func (q *Queries) SelectUserByID(ctx context.Context, id int64) (User, error) {
row := q.db.QueryRowContext(ctx, selectUserByID, id)
var i User
err := row.Scan(
&i.ID,
&i.Username,
&i.Password,
&i.CreatedAt,
)
2026-02-25 11:04:47 +00:00
return i, err
}
2026-02-19 11:29:44 +00:00
const selectUserByUsername = `-- name: SelectUserByUsername :one
SELECT id, username, password, created_at FROM users WHERE username = ? LIMIT 1
2026-02-19 11:29:44 +00:00
`
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,
&i.CreatedAt,
)
2026-02-19 11:29:44 +00:00
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
}