59 lines
992 B
Go
59 lines
992 B
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.25.0
|
|
// source: users.sql
|
|
|
|
package database
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const createUser = `-- name: CreateUser :exec
|
|
INSERT INTO users (id, created_at, updated_at, name, api_key)
|
|
VALUES (
|
|
?,
|
|
?,
|
|
?,
|
|
?,
|
|
?
|
|
)
|
|
`
|
|
|
|
type CreateUserParams struct {
|
|
ID string
|
|
CreatedAt string
|
|
UpdatedAt string
|
|
Name string
|
|
ApiKey string
|
|
}
|
|
|
|
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) error {
|
|
_, err := q.db.ExecContext(ctx, createUser,
|
|
arg.ID,
|
|
arg.CreatedAt,
|
|
arg.UpdatedAt,
|
|
arg.Name,
|
|
arg.ApiKey,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const getUser = `-- name: GetUser :one
|
|
|
|
SELECT id, created_at, updated_at, name, api_key FROM users WHERE api_key = ?
|
|
`
|
|
|
|
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
|
|
}
|