backend barebone done, big chunk of work done
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
)
|
||||
|
||||
// Store provides database access via a connection pool.
|
||||
type Store struct {
|
||||
pool *pgxpool.Pool
|
||||
}
|
||||
|
||||
// New creates a new Store with the given pgx pool.
|
||||
func New(pool *pgxpool.Pool) *Store {
|
||||
return &Store{pool: pool}
|
||||
}
|
||||
|
||||
// User represents a user account.
|
||||
type User struct {
|
||||
ID int64
|
||||
Username string
|
||||
DisplayName string
|
||||
PasswordHash string
|
||||
Avatar string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
// Session represents a user session for refresh tokens.
|
||||
type Session struct {
|
||||
ID int64
|
||||
UserID int64
|
||||
RefreshHash string
|
||||
ExpiresAt time.Time
|
||||
CreatedAt time.Time
|
||||
RevokedAt *time.Time
|
||||
UserAgent string
|
||||
IP string
|
||||
}
|
||||
|
||||
// Conversation represents a chat conversation.
|
||||
type Conversation struct {
|
||||
ID int64
|
||||
Type string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
// ConversationSummary provides a conversation with its last message and unread count.
|
||||
type ConversationSummary struct {
|
||||
Conversation
|
||||
LastMessage *Message
|
||||
UnreadCount int64
|
||||
}
|
||||
|
||||
// Message represents a message sent within a conversation.
|
||||
type Message struct {
|
||||
ID int64
|
||||
ConversationID int64
|
||||
SenderID int64
|
||||
Body string
|
||||
CreatedAt time.Time
|
||||
EditedAt *time.Time
|
||||
DeletedAt *time.Time
|
||||
}
|
||||
|
||||
// Contact represents a contact relationship between users.
|
||||
type Contact struct {
|
||||
OwnerID int64
|
||||
ContactID int64
|
||||
CreatedAt time.Time
|
||||
}
|
||||
Reference in New Issue
Block a user