moved the project to this repository
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.27.0
|
||||
// source: users.sql
|
||||
|
||||
package database
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const createUser = `-- name: CreateUser :one
|
||||
INSERT INTO users (id, created_at, updated_at, name, api_key)
|
||||
VALUES ($1, $2, $3, $4, encode(sha256(random()::text::bytea), 'hex'))
|
||||
RETURNING id, created_at, updated_at, name, api_key
|
||||
`
|
||||
|
||||
type CreateUserParams struct {
|
||||
ID uuid.UUID
|
||||
CreatedAt sql.NullTime
|
||||
UpdatedAt sql.NullTime
|
||||
Name string
|
||||
}
|
||||
|
||||
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error) {
|
||||
row := q.db.QueryRowContext(ctx, createUser,
|
||||
arg.ID,
|
||||
arg.CreatedAt,
|
||||
arg.UpdatedAt,
|
||||
arg.Name,
|
||||
)
|
||||
var i User
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.Name,
|
||||
&i.ApiKey,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getUser = `-- name: GetUser :one
|
||||
SELECT id, created_at, updated_at, name, api_key FROM users WHERE api_key = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetUser(ctx context.Context, apiKey string) (User, error) {
|
||||
row := q.db.QueryRowContext(ctx, getUser, apiKey)
|
||||
var i User
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.Name,
|
||||
&i.ApiKey,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
Reference in New Issue
Block a user