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,36 @@
package models
import (
"context"
"fmt"
"time"
)
// ChannelMember represents a user's membership in a channel.
type ChannelMember struct {
Base
ChannelID string `json:"channelId"`
UserID string `json:"userId"`
Modes string `json:"modes"`
JoinedAt time.Time `json:"joinedAt"`
Nick string `json:"nick"` // denormalized from users table
}
// User returns the full User for this membership.
func (cm *ChannelMember) User(ctx context.Context) (*User, error) {
if ul := cm.GetUserLookup(); ul != nil {
return ul.GetUserByID(ctx, cm.UserID)
}
return nil, fmt.Errorf("user lookup not available")
}
// Channel returns the full Channel for this membership.
func (cm *ChannelMember) Channel(ctx context.Context) (*Channel, error) {
if cl := cm.GetChannelLookup(); cl != nil {
return cl.GetChannelByID(ctx, cm.ChannelID)
}
return nil, fmt.Errorf("channel lookup not available")
}