summaryrefslogtreecommitdiff
path: root/model/users.sql.go
diff options
context:
space:
mode:
Diffstat (limited to 'model/users.sql.go')
-rw-r--r--model/users.sql.go93
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
+}