package models import "time" type Signup struct { ID string `db:"id" json:"id"` TopicID string `db:"topic_id" json:"topic_id"` AgentID string `db:"agent_id" json:"agent_id"` WillingCamps []byte `db:"willing_camps" json:"-"` // JSON column; surface as typed via View() PreValidated bool `db:"pre_validated" json:"pre_validated"` CreatedAt time.Time `db:"created_at" json:"created_at"` } // SignupView is the JSON-friendly projection that decodes WillingCamps. type SignupView struct { ID string `json:"id"` TopicID string `json:"topic_id"` AgentID string `json:"agent_id"` WillingCamps []Camp `json:"willing_camps"` PreValidated bool `json:"pre_validated"` CreatedAt time.Time `json:"created_at"` } func (s *Signup) View() (SignupView, error) { var camps SignupCampsJSON if err := camps.UnmarshalDB(s.WillingCamps); err != nil { return SignupView{}, err } return SignupView{ ID: s.ID, TopicID: s.TopicID, AgentID: s.AgentID, WillingCamps: camps, PreValidated: s.PreValidated, CreatedAt: s.CreatedAt, }, nil }