54 lines
1.2 KiB
Go
54 lines
1.2 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.28.0
|
|
// source: users.sql
|
|
|
|
package dbq
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const addUser = `-- name: AddUser :one
|
|
INSERT INTO users (
|
|
email,
|
|
password
|
|
) VALUES ($1, $2)
|
|
ON CONFLICT (email) DO UPDATE SET password = $2
|
|
RETURNING id
|
|
`
|
|
|
|
type AddUserParams struct {
|
|
Email string
|
|
Password string
|
|
}
|
|
|
|
func (q *Queries) AddUser(ctx context.Context, arg AddUserParams) (int64, error) {
|
|
row := q.db.QueryRow(ctx, addUser, arg.Email, arg.Password)
|
|
var id int64
|
|
err := row.Scan(&id)
|
|
return id, err
|
|
}
|
|
|
|
const getUserByEmail = `-- name: GetUserByEmail :one
|
|
SELECT id, email, password FROM users WHERE email = $1 LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetUserByEmail(ctx context.Context, email string) (User, error) {
|
|
row := q.db.QueryRow(ctx, getUserByEmail, email)
|
|
var i User
|
|
err := row.Scan(&i.ID, &i.Email, &i.Password)
|
|
return i, err
|
|
}
|
|
|
|
const getUserByID = `-- name: GetUserByID :one
|
|
SELECT id, email, password FROM users WHERE id = $1 LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetUserByID(ctx context.Context, id int64) (User, error) {
|
|
row := q.db.QueryRow(ctx, getUserByID, id)
|
|
var i User
|
|
err := row.Scan(&i.ID, &i.Email, &i.Password)
|
|
return i, err
|
|
}
|