ekster/pkg/microsub/database.go
Peter Stuifzand cb9acf31ad
Some checks failed
continuous-integration/drone/push Build is failing
Add code for postgres-stream
2021-05-11 17:28:52 +02:00

23 lines
429 B
Go

package microsub
import (
"database/sql/driver"
"encoding/json"
"errors"
)
// Scan helps to scan json data from database
func (item *Item) Scan(value interface{}) error {
b, ok := value.([]byte)
if !ok {
return errors.New("type assertion to []byte failed")
}
return json.Unmarshal(b, &item)
}
// Value helps to add json data to database
func (item *Item) Value() (driver.Value, error) {
return json.Marshal(item)
}