-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* use go modules * do not use dep for travis * Use github.com/putdotio/pas as module name * run inside docker containers * move go-mod files above to prevent download modules for each run * Add Json field support
- Loading branch information
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,7 @@ email = "string" | |
|
||
[Events.page_viewed] | ||
path = "string" | ||
|
||
[Events.event_foo] | ||
name = "string" | ||
data = "json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package property | ||
|
||
import ( | ||
"database/sql/driver" | ||
"encoding/json" | ||
"fmt" | ||
) | ||
|
||
type Json struct{} | ||
|
||
func newJson(args []string) (typeInterface, error) { | ||
if len(args) > 0 { | ||
return nil, fmt.Errorf("invalid arguments: %q", args) | ||
} | ||
return Json{}, nil | ||
} | ||
|
||
func (j Json) ColumnType() string { | ||
return "json" | ||
} | ||
|
||
func (j Json) ConvertValue(v interface{}) (driver.Value, error) { | ||
b, err := json.Marshal(v) | ||
if err != nil { | ||
return nil, fmt.Errorf("value is not json: %v", v) | ||
} | ||
return b, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters