Documentation
¶
Overview ¶
Package domain define el modelo de la superapp. Las entidades se eligen para FORZAR la amplitud de la API de Quark, no por valor de producto: relaciones (has_many/belongs_to/many_to_many), soft-delete, optimistic lock, PK compuesta, []byte y los tipos ricos (JSON[T]/Array[T]/Nullable[T]/tz).
Tags verificados contra website/docs/guides/modeling.mdx.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Account ¶
type Account struct {
ID int64 `db:"id" pk:"true"`
Email string `db:"email" quark:"unique,not_null" validate:"required,email"`
Name string `db:"name" quark:"not_null"`
Role string `db:"role" default:"'member'" validate:"oneof=admin member viewer"`
Active bool `db:"active" default:"1"` // portable: el migrator normaliza el bool default por dialecto (PR #170)
Bio quark.Nullable[string] `db:"bio,size=512"`
Settings quark.JSON[AccountPrefs] `db:"settings"`
Tags quark.Array[string] `db:"tags"`
LastLogin quark.Nullable[time.Time] `db:"last_login" quark:"tz=Europe/Madrid"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
DeletedAt *time.Time `db:"deleted_at"`
Version int64 `db:"version" quark:"version"`
// Relación (no es columna).
Projects []Project `rel:"has_many" join:"owner_id"`
}
Account ejerce: tipos ricos (Nullable/JSON/Array), tz por columna, optimistic lock (version), soft delete (deleted_at), validación tag+método, y hooks Before*.
type AccountPrefs ¶
AccountPrefs es el payload de la columna JSON de Account.
type Attachment ¶
type Attachment struct {
ID int64 `db:"id" pk:"true"`
TaskID int64 `db:"task_id" quark:"not_null"`
Name string `db:"name" quark:"not_null"`
Bytes []byte `db:"bytes"`
Optional quark.Nullable[[]byte] `db:"optional"`
}
Attachment ejerce binario []byte y Nullable[[]byte] (el caso del fix BB-6 de MSSQL: NULL []byte sobre nvarchar/varbinary).
type Membership ¶
type Membership struct {
AccountID int64 `db:"account_id" pk:"true"`
ProjectID int64 `db:"project_id" pk:"true"`
Role string `db:"role" default:"'member'"`
JoinedAt time.Time `db:"joined_at"`
}
Membership ejerce PK COMPUESTA (account_id, project_id) y TableName().
func (Membership) TableName ¶
func (Membership) TableName() string
type Project ¶
type Project struct {
ID int64 `db:"id" pk:"true"`
OwnerID int64 `db:"owner_id" quark:"not_null"`
Name string `db:"name" quark:"not_null"`
Status string `db:"status" default:"'draft'"`
CreatedAt time.Time `db:"created_at"`
DeletedAt *time.Time `db:"deleted_at"`
Owner *Account `rel:"belongs_to" join:"owner_id"`
Tasks []Task `rel:"has_many" join:"project_id"`
// m2m: tag confirmado vs website/docs/guides/relations.mdx —
// formato `m2m:"<tabla_join>:<fk_este>:<fk_otro>"`. Migrate crea project_tags.
Tags []Tag `rel:"many_to_many" m2m:"project_tags:project_id:tag_id"`
}
Project ejerce belongs_to (Owner), has_many (Tasks), many_to_many (Tags) y soft delete.
type Task ¶
type Task struct {
ID int64 `db:"id" pk:"true"`
ProjectID int64 `db:"project_id" quark:"not_null"`
Title string `db:"title" quark:"not_null"`
Done bool `db:"done" default:"0"` // portable tras el fix del migrator (PR #170)
AssigneeID *int64 `db:"assignee_id"` // FK nullable (BB-5)
DueAt quark.Nullable[time.Time] `db:"due_at"`
Priority int `db:"priority" default:"0"`
Project *Project `rel:"belongs_to" join:"project_id"`
Assignee *Account `rel:"belongs_to" join:"assignee_id"`
}
Task ejerce belongs_to + una FK NULLABLE (*int64) que Preload debe seguir sin cargar basura — el caso del fix BB-5.