diff --git a/internal/db/models.go b/internal/db/models.go index c980831..ff508e4 100644 --- a/internal/db/models.go +++ b/internal/db/models.go @@ -8,6 +8,14 @@ import ( "github.com/jackc/pgx/v5/pgtype" ) +type RefreshToken struct { + ID int64 `json:"id"` + UserID int64 `json:"user_id"` + TokenHash string `json:"token_hash"` + CreatedAt pgtype.Timestamptz `json:"created_at"` + ExpiresAt pgtype.Timestamptz `json:"expires_at"` +} + type User struct { ID int64 `json:"id"` Email string `json:"email"` diff --git a/internal/db/querier.go b/internal/db/querier.go index 4009e44..89a212b 100644 --- a/internal/db/querier.go +++ b/internal/db/querier.go @@ -9,8 +9,12 @@ import ( ) type Querier interface { + CreateRefreshToken(ctx context.Context, arg CreateRefreshTokenParams) (RefreshToken, error) CreateUser(ctx context.Context, arg CreateUserParams) (User, error) + DeleteAllUserRefreshTokens(ctx context.Context, userID int64) error + DeleteRefreshToken(ctx context.Context, tokenHash string) error DeleteUser(ctx context.Context, arg DeleteUserParams) error + GetRefreshToken(ctx context.Context, tokenHash string) (RefreshToken, error) GetUserByEmail(ctx context.Context, dollar_1 string) (User, error) GetUserById(ctx context.Context, id int64) (User, error) ListUsers(ctx context.Context) ([]User, error)