go-project-template/db/users.sql.go

49 lines
1.2 KiB
Go
Raw Permalink Normal View History

2024-07-25 05:13:23 +00:00
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.20.0
// source: users.sql
package db
import (
"context"
)
const createUser = `-- name: CreateUser :one
INSERT INTO users (username, idp_sub) VALUES ($1, $2) RETURNING id, idp_sub, username
`
type CreateUserParams struct {
Username string
IdpSub string
}
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error) {
row := q.db.QueryRow(ctx, createUser, arg.Username, arg.IdpSub)
var i User
err := row.Scan(&i.ID, &i.IdpSub, &i.Username)
return i, err
}
const getUser = `-- name: GetUser :one
SELECT id, idp_sub, username FROM users WHERE id = $1 LIMIT 1
`
func (q *Queries) GetUser(ctx context.Context, id int32) (User, error) {
row := q.db.QueryRow(ctx, getUser, id)
var i User
err := row.Scan(&i.ID, &i.IdpSub, &i.Username)
return i, err
}
const getUserByIDP = `-- name: GetUserByIDP :one
SELECT id, idp_sub, username FROM users WHERE idp_sub = $1 LIMIT 1
`
func (q *Queries) GetUserByIDP(ctx context.Context, idpSub string) (User, error) {
row := q.db.QueryRow(ctx, getUserByIDP, idpSub)
var i User
err := row.Scan(&i.ID, &i.IdpSub, &i.Username)
return i, err
}