Add models package with embedded DB interface pattern

- internal/models/model.go: DB interface + Base struct for all models
- internal/models/channel.go: Channel model with DB access for relation queries
- Database.NewChannel() factory injects db reference into model instances
- Uses interface to avoid circular imports (models -> db)
This commit is contained in:
clawbot
2026-02-09 12:24:23 -08:00
parent 8bb083a7f8
commit 5e9be8ccaf
3 changed files with 69 additions and 8 deletions

View File

@@ -0,0 +1,21 @@
package models
import (
"time"
)
// Channel represents a chat channel.
type Channel struct {
Base
ID int64 `json:"id"`
Name string `json:"name"`
Topic string `json:"topic"`
Modes string `json:"modes"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// Example relation method — will be fleshed out when we add channel_members:
// func (c *Channel) Members(ctx context.Context) ([]*User, error) {
// return c.DB().GetChannelMembers(ctx, c.ID)
// }