kinda working
This commit is contained in:
59
internal/database/users.sql.go
Normal file
59
internal/database/users.sql.go
Normal file
@@ -0,0 +1,59 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.18.0
|
||||
// source: users.sql
|
||||
|
||||
package database
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
const createUser = `-- name: CreateUser :exec
|
||||
INSERT INTO users (id, created_at, updated_at, name, api_key)
|
||||
VALUES (
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?
|
||||
)
|
||||
`
|
||||
|
||||
type CreateUserParams struct {
|
||||
ID string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
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 getUserByAPIKey = `-- name: GetUserByAPIKey :one
|
||||
|
||||
SELECT id, created_at, updated_at, name, api_key FROM users WHERE api_key = ?
|
||||
`
|
||||
|
||||
func (q *Queries) GetUserByAPIKey(ctx context.Context, apiKey string) (User, error) {
|
||||
row := q.db.QueryRowContext(ctx, getUserByAPIKey, 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