hiling_go/db/sqlc/sessions.sql.go

82 lines
1.7 KiB
Go
Raw Permalink Normal View History

2023-09-21 21:38:41 +07:00
// Code generated by sqlc. DO NOT EDIT.
// versions:
2024-02-06 11:55:25 +07:00
// sqlc v1.25.0
2023-09-21 21:38:41 +07:00
// source: sessions.sql
package db
import (
"context"
2024-02-06 11:55:25 +07:00
"github.com/jackc/pgx/v5/pgtype"
2023-09-21 21:38:41 +07:00
)
const createSession = `-- name: CreateSession :one
INSERT INTO user_sessions (
username,
refresh_token,
user_agent,
client_ip,
is_blocked,
expires_at
) VALUES (
$1, $2, $3, $4, $5, $6
) RETURNING id, index_id, username, refresh_token, user_agent, client_ip, is_blocked, expires_at, created_at
`
type CreateSessionParams struct {
2024-02-06 11:55:25 +07:00
Username string `json:"username"`
RefreshToken string `json:"refresh_token"`
UserAgent string `json:"user_agent"`
ClientIp string `json:"client_ip"`
IsBlocked bool `json:"is_blocked"`
ExpiresAt pgtype.Timestamp `json:"expires_at"`
2023-09-21 21:38:41 +07:00
}
func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) (UserSession, error) {
2024-02-06 11:55:25 +07:00
row := q.db.QueryRow(ctx, createSession,
2023-09-21 21:38:41 +07:00
arg.Username,
arg.RefreshToken,
arg.UserAgent,
arg.ClientIp,
arg.IsBlocked,
arg.ExpiresAt,
)
var i UserSession
err := row.Scan(
&i.ID,
&i.IndexID,
&i.Username,
&i.RefreshToken,
&i.UserAgent,
&i.ClientIp,
&i.IsBlocked,
&i.ExpiresAt,
&i.CreatedAt,
)
return i, err
}
const getSession = `-- name: GetSession :one
SELECT id, index_id, username, refresh_token, user_agent, client_ip, is_blocked, expires_at, created_at FROM user_sessions
WHERE id = $1
LIMIT 1
`
func (q *Queries) GetSession(ctx context.Context, id int32) (UserSession, error) {
2024-02-06 11:55:25 +07:00
row := q.db.QueryRow(ctx, getSession, id)
2023-09-21 21:38:41 +07:00
var i UserSession
err := row.Scan(
&i.ID,
&i.IndexID,
&i.Username,
&i.RefreshToken,
&i.UserAgent,
&i.ClientIp,
&i.IsBlocked,
&i.ExpiresAt,
&i.CreatedAt,
)
return i, err
}