11 "github.com/lib/pq/hstore"
14 type Hstore map[string]*string
16 // Value get value of Hstore
17 func (h Hstore) Value() (driver.Value, error) {
18 hstore := hstore.Hstore{Map: map[string]sql.NullString{}}
23 for key, value := range h {
34 // Scan scan value into Hstore
35 func (h *Hstore) Scan(value interface{}) error {
36 hstore := hstore.Hstore{}
38 if err := hstore.Scan(value); err != nil {
42 if len(hstore.Map) == 0 {
47 for k := range hstore.Map {
48 if hstore.Map[k].Valid {
49 s := hstore.Map[k].String
59 // Jsonb Postgresql's JSONB data type
64 // Value get value of Jsonb
65 func (j Jsonb) Value() (driver.Value, error) {
66 if len(j.RawMessage) == 0 {
69 return j.MarshalJSON()
72 // Scan scan value into Jsonb
73 func (j *Jsonb) Scan(value interface{}) error {
74 bytes, ok := value.([]byte)
76 return errors.New(fmt.Sprint("Failed to unmarshal JSONB value:", value))
79 return json.Unmarshal(bytes, j)