taskcafe/api/pg/user_accounts.sql.go

122 lines
2.9 KiB
Go
Raw Normal View History

2020-04-10 04:40:22 +02:00
// Code generated by sqlc. DO NOT EDIT.
// source: user_accounts.sql
package pg
import (
"context"
"time"
"github.com/google/uuid"
)
const createUserAccount = `-- name: CreateUserAccount :one
2020-04-20 05:02:55 +02:00
INSERT INTO user_account(first_name, last_name, email, username, created_at, password_hash)
VALUES ($1, $2, $3, $4, $5, $6)
RETURNING user_id, created_at, first_name, last_name, email, username, password_hash
2020-04-10 04:40:22 +02:00
`
type CreateUserAccountParams struct {
2020-04-20 05:02:55 +02:00
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
2020-04-10 04:40:22 +02:00
Email string `json:"email"`
Username string `json:"username"`
CreatedAt time.Time `json:"created_at"`
PasswordHash string `json:"password_hash"`
}
func (q *Queries) CreateUserAccount(ctx context.Context, arg CreateUserAccountParams) (UserAccount, error) {
row := q.db.QueryRowContext(ctx, createUserAccount,
2020-04-20 05:02:55 +02:00
arg.FirstName,
arg.LastName,
2020-04-10 04:40:22 +02:00
arg.Email,
arg.Username,
arg.CreatedAt,
arg.PasswordHash,
)
var i UserAccount
err := row.Scan(
&i.UserID,
&i.CreatedAt,
2020-04-20 05:02:55 +02:00
&i.FirstName,
&i.LastName,
2020-04-10 04:40:22 +02:00
&i.Email,
&i.Username,
&i.PasswordHash,
)
return i, err
}
const getAllUserAccounts = `-- name: GetAllUserAccounts :many
2020-04-20 05:02:55 +02:00
SELECT user_id, created_at, first_name, last_name, email, username, password_hash FROM user_account
2020-04-10 04:40:22 +02:00
`
func (q *Queries) GetAllUserAccounts(ctx context.Context) ([]UserAccount, error) {
rows, err := q.db.QueryContext(ctx, getAllUserAccounts)
if err != nil {
return nil, err
}
defer rows.Close()
var items []UserAccount
for rows.Next() {
var i UserAccount
if err := rows.Scan(
&i.UserID,
&i.CreatedAt,
2020-04-20 05:02:55 +02:00
&i.FirstName,
&i.LastName,
2020-04-10 04:40:22 +02:00
&i.Email,
&i.Username,
&i.PasswordHash,
); 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
}
const getUserAccountByID = `-- name: GetUserAccountByID :one
2020-04-20 05:02:55 +02:00
SELECT user_id, created_at, first_name, last_name, email, username, password_hash FROM user_account WHERE user_id = $1
2020-04-10 04:40:22 +02:00
`
func (q *Queries) GetUserAccountByID(ctx context.Context, userID uuid.UUID) (UserAccount, error) {
row := q.db.QueryRowContext(ctx, getUserAccountByID, userID)
var i UserAccount
err := row.Scan(
&i.UserID,
&i.CreatedAt,
2020-04-20 05:02:55 +02:00
&i.FirstName,
&i.LastName,
2020-04-10 04:40:22 +02:00
&i.Email,
&i.Username,
&i.PasswordHash,
)
return i, err
}
const getUserAccountByUsername = `-- name: GetUserAccountByUsername :one
2020-04-20 05:02:55 +02:00
SELECT user_id, created_at, first_name, last_name, email, username, password_hash FROM user_account WHERE username = $1
2020-04-10 04:40:22 +02:00
`
func (q *Queries) GetUserAccountByUsername(ctx context.Context, username string) (UserAccount, error) {
row := q.db.QueryRowContext(ctx, getUserAccountByUsername, username)
var i UserAccount
err := row.Scan(
&i.UserID,
&i.CreatedAt,
2020-04-20 05:02:55 +02:00
&i.FirstName,
&i.LastName,
2020-04-10 04:40:22 +02:00
&i.Email,
&i.Username,
&i.PasswordHash,
)
return i, err
}