diff options
author | René 'Necoro' Neumann <necoro@necoro.eu> | 2024-02-14 23:38:53 +0100 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.eu> | 2024-02-14 23:38:53 +0100 |
commit | b3485c78114e505b7bc9c6969afa108ea3f4755c (patch) | |
tree | 440b6ac6d2f29074945294a66929d8a12fe30505 /model/users.sql.go | |
parent | 90acc67af9a7d372be5fa9cab7a34412ce4ad824 (diff) | |
download | gosten-b3485c78114e505b7bc9c6969afa108ea3f4755c.tar.gz gosten-b3485c78114e505b7bc9c6969afa108ea3f4755c.tar.bz2 gosten-b3485c78114e505b7bc9c6969afa108ea3f4755c.zip |
Remove sqlite support: the differences with sqlc just get too cumbersome
Diffstat (limited to 'model/users.sql.go')
-rw-r--r-- | model/users.sql.go | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/model/users.sql.go b/model/users.sql.go new file mode 100644 index 0000000..87ae961 --- /dev/null +++ b/model/users.sql.go @@ -0,0 +1,93 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.25.0 +// source: users.sql + +package model + +import ( + "context" +) + +const getUserById = `-- name: GetUserById :one +SELECT id, name, pwd, description + FROM users + WHERE id = ? +` + +// GetUserById +// +// SELECT id, name, pwd, description +// FROM users +// WHERE id = ? +func (q *Queries) GetUserById(ctx context.Context, id int32) (User, error) { + row := q.db.QueryRowContext(ctx, getUserById, id) + var i User + err := row.Scan( + &i.ID, + &i.Name, + &i.Pwd, + &i.Description, + ) + return i, err +} + +const getUserByName = `-- name: GetUserByName :one +SELECT id, name, pwd, description + FROM users + WHERE LOWER(name) = LOWER(?) +` + +// GetUserByName +// +// SELECT id, name, pwd, description +// FROM users +// WHERE LOWER(name) = LOWER(?) +func (q *Queries) GetUserByName(ctx context.Context, lower string) (User, error) { + row := q.db.QueryRowContext(ctx, getUserByName, lower) + var i User + err := row.Scan( + &i.ID, + &i.Name, + &i.Pwd, + &i.Description, + ) + return i, err +} + +const getUsers = `-- name: GetUsers :many +SELECT id, name, pwd, description + FROM users +` + +// GetUsers +// +// SELECT id, name, pwd, description +// FROM users +func (q *Queries) GetUsers(ctx context.Context) ([]User, error) { + rows, err := q.db.QueryContext(ctx, getUsers) + if err != nil { + return nil, err + } + defer rows.Close() + var items []User + for rows.Next() { + var i User + if err := rows.Scan( + &i.ID, + &i.Name, + &i.Pwd, + &i.Description, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} |