// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.14.0
// source: sessions_gen.sql

package core_repo

import (
	"context"
	"time"

	"github.com/google/uuid"
)

const createSession = `-- name: CreateSession :one

INSERT INTO "public"."_sessions" 
(id,user_id,client_ip,user_agent,refresh_token,blocked,expires) 
VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING id, user_id, client_ip, user_agent, refresh_token, blocked, expires, created
`

type CreateSessionParams struct {
	ID           uuid.UUID `json:"id"`
	UserID       int64     `json:"user_id"`
	ClientIp     string    `json:"client_ip"`
	UserAgent    string    `json:"user_agent"`
	RefreshToken string    `json:"refresh_token"`
	Blocked      bool      `json:"blocked"`
	Expires      time.Time `json:"expires"`
}

// -------------------------- ADD ONE TO -> _SESSIONS --------------------------
func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error) {
	row := q.db.QueryRowContext(ctx, createSession,
		arg.ID,
		arg.UserID,
		arg.ClientIp,
		arg.UserAgent,
		arg.RefreshToken,
		arg.Blocked,
		arg.Expires,
	)
	var i Session
	err := row.Scan(
		&i.ID,
		&i.UserID,
		&i.ClientIp,
		&i.UserAgent,
		&i.RefreshToken,
		&i.Blocked,
		&i.Expires,
		&i.Created,
	)
	return i, err
}

const getSession = `-- name: GetSession :one

SELECT id, user_id, client_ip, user_agent, refresh_token, blocked, expires, created FROM "public"."_sessions" WHERE id = $1 LIMIT 1
`

// -------------------------- GET ONE FROM <- _SESSIONS --------------------------
func (q *Queries) GetSession(ctx context.Context, id uuid.UUID) (Session, error) {
	row := q.db.QueryRowContext(ctx, getSession, id)
	var i Session
	err := row.Scan(
		&i.ID,
		&i.UserID,
		&i.ClientIp,
		&i.UserAgent,
		&i.RefreshToken,
		&i.Blocked,
		&i.Expires,
		&i.Created,
	)
	return i, err
}
