diff --git a/crm/types/types.go b/crm/types/types.go index 55c8a489d..5fd674a54 100644 --- a/crm/types/types.go +++ b/crm/types/types.go @@ -3,6 +3,9 @@ package types import ( "time" + "database/sql/driver" + "encoding/json" + "github.com/jmoiron/sqlx/types" systemTypes "github.com/crusttech/crust/system/types" @@ -53,7 +56,7 @@ type ( Module struct { ID uint64 `json:"moduleID,string" db:"id"` Name string `json:"name" db:"name"` - Fields types.JSONText `json:"fields" db:"json"` + Fields ModuleFieldSet `json:"fields" db:"json"` Page *Page `json:"page,omitempty"` @@ -81,6 +84,8 @@ type ( Visible bool `json:"isVisible" db:"is_visible"` } + ModuleFieldSet []ModuleField + // Page - page structure Page struct { ID uint64 `json:"pageID,string" db:"id"` @@ -112,3 +117,14 @@ type ( Height int `json:"height"` } ) + +func (f *ModuleFieldSet) Scan(src interface{}) error { + if data, ok := src.([]byte); ok { + return json.Unmarshal(data, f) + } + return nil +} + +func (f ModuleFieldSet) Value() (driver.Value, error) { + return json.Marshal(f) +}