Code formatting
This commit is contained in:
@@ -9,9 +9,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type MessageEventResponse struct {
|
type MessageEventResponse struct {
|
||||||
Id uuid.UUID `json:"id,omitempty"`
|
Id uuid.UUID `json:"id,omitempty"`
|
||||||
ScheduledMessageEventId uuid.UUID `json:"scheduled_message_event_id,omitempty"`
|
ScheduledMessageEventId uuid.UUID `json:"scheduled_message_event_id,omitempty"`
|
||||||
Response types.JSONB `json:"response"`
|
Response types.JSONB `json:"response"`
|
||||||
UserId uuid.UUID `json:"user_id,omitempty"`
|
UserId uuid.UUID `json:"user_id,omitempty"`
|
||||||
Sent time.Time `json:"sent"`
|
Sent time.Time `json:"sent"`
|
||||||
}
|
}
|
||||||
|
|||||||
+24
-25
@@ -6,37 +6,36 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
type JSONB json.RawMessage
|
type JSONB json.RawMessage
|
||||||
|
|
||||||
// Scan implements sql.Scanner
|
// Scan implements sql.Scanner
|
||||||
func (j *JSONB) Scan(value interface{}) error {
|
func (j *JSONB) Scan(value interface{}) error {
|
||||||
if value == nil {
|
if value == nil {
|
||||||
*j = nil
|
*j = nil
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var data []byte
|
var data []byte
|
||||||
switch v := value.(type) {
|
switch v := value.(type) {
|
||||||
case []byte:
|
case []byte:
|
||||||
// pgx may pass data as []byte in binary format
|
// pgx may pass data as []byte in binary format
|
||||||
data = v
|
data = v
|
||||||
case string:
|
case string:
|
||||||
// pgx may pass data as string in text format
|
// pgx may pass data as string in text format
|
||||||
data = []byte(v)
|
data = []byte(v)
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("unsupported type: %T", v)
|
return fmt.Errorf("unsupported type: %T", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
*j = JSONB(data)
|
*j = JSONB(data)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Value implements driver.Valuer
|
// Value implements driver.Valuer
|
||||||
func (j JSONB) Value() (driver.Value, error) {
|
func (j JSONB) Value() (driver.Value, error) {
|
||||||
if j == nil {
|
if j == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
} else {
|
} else {
|
||||||
return []byte(j), nil
|
return []byte(j), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user