mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-12-25 01:22:30 +00:00
162 lines
3.1 KiB
Go
162 lines
3.1 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: query.sql
|
|
|
|
package repository
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const createSession = `-- name: CreateSession :one
|
|
INSERT INTO sessions (
|
|
"uuid",
|
|
"username",
|
|
"email",
|
|
"name",
|
|
"provider",
|
|
"totp_pending",
|
|
"oauth_groups",
|
|
"expiry",
|
|
"oauth_name"
|
|
) VALUES (
|
|
?, ?, ?, ?, ?, ?, ?, ?, ?
|
|
)
|
|
RETURNING uuid, username, email, name, provider, totp_pending, oauth_groups, expiry, oauth_name
|
|
`
|
|
|
|
type CreateSessionParams struct {
|
|
UUID string
|
|
Username string
|
|
Email string
|
|
Name string
|
|
Provider string
|
|
TotpPending bool
|
|
OAuthGroups string
|
|
Expiry int64
|
|
OAuthName string
|
|
}
|
|
|
|
func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error) {
|
|
row := q.db.QueryRowContext(ctx, createSession,
|
|
arg.UUID,
|
|
arg.Username,
|
|
arg.Email,
|
|
arg.Name,
|
|
arg.Provider,
|
|
arg.TotpPending,
|
|
arg.OAuthGroups,
|
|
arg.Expiry,
|
|
arg.OAuthName,
|
|
)
|
|
var i Session
|
|
err := row.Scan(
|
|
&i.UUID,
|
|
&i.Username,
|
|
&i.Email,
|
|
&i.Name,
|
|
&i.Provider,
|
|
&i.TotpPending,
|
|
&i.OAuthGroups,
|
|
&i.Expiry,
|
|
&i.OAuthName,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const deleteExpiredSessions = `-- name: DeleteExpiredSessions :exec
|
|
DELETE FROM "sessions"
|
|
WHERE "expiry" < ?
|
|
`
|
|
|
|
func (q *Queries) DeleteExpiredSessions(ctx context.Context, expiry int64) error {
|
|
_, err := q.db.ExecContext(ctx, deleteExpiredSessions, expiry)
|
|
return err
|
|
}
|
|
|
|
const deleteSession = `-- name: DeleteSession :exec
|
|
DELETE FROM "sessions"
|
|
WHERE "uuid" = ?
|
|
`
|
|
|
|
func (q *Queries) DeleteSession(ctx context.Context, uuid string) error {
|
|
_, err := q.db.ExecContext(ctx, deleteSession, uuid)
|
|
return err
|
|
}
|
|
|
|
const getSession = `-- name: GetSession :one
|
|
SELECT uuid, username, email, name, provider, totp_pending, oauth_groups, expiry, oauth_name FROM "sessions"
|
|
WHERE "uuid" = ?
|
|
`
|
|
|
|
func (q *Queries) GetSession(ctx context.Context, uuid string) (Session, error) {
|
|
row := q.db.QueryRowContext(ctx, getSession, uuid)
|
|
var i Session
|
|
err := row.Scan(
|
|
&i.UUID,
|
|
&i.Username,
|
|
&i.Email,
|
|
&i.Name,
|
|
&i.Provider,
|
|
&i.TotpPending,
|
|
&i.OAuthGroups,
|
|
&i.Expiry,
|
|
&i.OAuthName,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateSession = `-- name: UpdateSession :one
|
|
UPDATE "sessions" SET
|
|
"username" = ?,
|
|
"email" = ?,
|
|
"name" = ?,
|
|
"provider" = ?,
|
|
"totp_pending" = ?,
|
|
"oauth_groups" = ?,
|
|
"expiry" = ?,
|
|
"oauth_name" = ?
|
|
WHERE "uuid" = ?
|
|
RETURNING uuid, username, email, name, provider, totp_pending, oauth_groups, expiry, oauth_name
|
|
`
|
|
|
|
type UpdateSessionParams struct {
|
|
Username string
|
|
Email string
|
|
Name string
|
|
Provider string
|
|
TotpPending bool
|
|
OAuthGroups string
|
|
Expiry int64
|
|
OAuthName string
|
|
UUID string
|
|
}
|
|
|
|
func (q *Queries) UpdateSession(ctx context.Context, arg UpdateSessionParams) (Session, error) {
|
|
row := q.db.QueryRowContext(ctx, updateSession,
|
|
arg.Username,
|
|
arg.Email,
|
|
arg.Name,
|
|
arg.Provider,
|
|
arg.TotpPending,
|
|
arg.OAuthGroups,
|
|
arg.Expiry,
|
|
arg.OAuthName,
|
|
arg.UUID,
|
|
)
|
|
var i Session
|
|
err := row.Scan(
|
|
&i.UUID,
|
|
&i.Username,
|
|
&i.Email,
|
|
&i.Name,
|
|
&i.Provider,
|
|
&i.TotpPending,
|
|
&i.OAuthGroups,
|
|
&i.Expiry,
|
|
&i.OAuthName,
|
|
)
|
|
return i, err
|
|
}
|