Add complete database schema and ORM models (#4)

This commit was merged in pull request #4.
This commit is contained in:
2026-02-11 03:02:33 +01:00
parent 03cbc3cd1a
commit 95ccc1b2cd
13 changed files with 1457 additions and 47 deletions

View File

@@ -0,0 +1,27 @@
package models
import (
"context"
"fmt"
"time"
)
// AuthToken represents an authentication token for a user session.
type AuthToken struct {
Base
Token string `json:"-"`
UserID string `json:"userId"`
CreatedAt time.Time `json:"createdAt"`
ExpiresAt *time.Time `json:"expiresAt,omitempty"`
LastUsedAt *time.Time `json:"lastUsedAt,omitempty"`
}
// User returns the user who owns this token.
func (t *AuthToken) User(ctx context.Context) (*User, error) {
if ul := t.GetUserLookup(); ul != nil {
return ul.GetUserByID(ctx, t.UserID)
}
return nil, fmt.Errorf("user lookup not available")
}