build get set null value

This commit is contained in:
Tue 2022-10-04 11:42:43 +07:00
parent e84d973c29
commit 2d04035236
2 changed files with 14 additions and 0 deletions

7
get.go
View File

@ -32,3 +32,10 @@ func GetTime(val null.Time) (res time.Time) {
}
return val.Time
}
func GetJSON(val null.JSON) (res []byte) {
if !val.Valid {
return
}
return val.JSON
}

7
set.go
View File

@ -32,3 +32,10 @@ func SetTime(val time.Time) null.Time {
Valid: true,
}
}
func SetJSON(val []byte) null.JSON {
return null.JSON{
JSON: val,
Valid: true,
}
}