95 lines
2.2 KiB
Go
95 lines
2.2 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: users.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
)
|
|
|
|
const createUser = `-- name: CreateUser :one
|
|
INSERT INTO users (email, ory_identity_id)
|
|
VALUES ($1, $2)
|
|
RETURNING id, email, created_at, ory_identity_id, is_admin
|
|
`
|
|
|
|
type CreateUserParams struct {
|
|
Email string `json:"email"`
|
|
OryIdentityID sql.NullString `json:"ory_identity_id"`
|
|
}
|
|
|
|
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, createUser, arg.Email, arg.OryIdentityID)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Email,
|
|
&i.CreatedAt,
|
|
&i.OryIdentityID,
|
|
&i.IsAdmin,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUserByEmail = `-- name: GetUserByEmail :one
|
|
SELECT id, email, created_at, ory_identity_id, is_admin FROM users WHERE email = $1 LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetUserByEmail(ctx context.Context, email string) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, getUserByEmail, email)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Email,
|
|
&i.CreatedAt,
|
|
&i.OryIdentityID,
|
|
&i.IsAdmin,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUserByOryID = `-- name: GetUserByOryID :one
|
|
SELECT id, email, created_at, ory_identity_id, is_admin FROM users WHERE ory_identity_id = $1 LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetUserByOryID(ctx context.Context, oryIdentityID sql.NullString) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, getUserByOryID, oryIdentityID)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Email,
|
|
&i.CreatedAt,
|
|
&i.OryIdentityID,
|
|
&i.IsAdmin,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateUserOryID = `-- name: UpdateUserOryID :one
|
|
UPDATE users
|
|
SET ory_identity_id = $1
|
|
WHERE email = $2
|
|
RETURNING id, email, created_at, ory_identity_id, is_admin
|
|
`
|
|
|
|
type UpdateUserOryIDParams struct {
|
|
OryIdentityID sql.NullString `json:"ory_identity_id"`
|
|
Email string `json:"email"`
|
|
}
|
|
|
|
func (q *Queries) UpdateUserOryID(ctx context.Context, arg UpdateUserOryIDParams) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, updateUserOryID, arg.OryIdentityID, arg.Email)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Email,
|
|
&i.CreatedAt,
|
|
&i.OryIdentityID,
|
|
&i.IsAdmin,
|
|
)
|
|
return i, err
|
|
}
|