From 2d04035236f9ca02082ea8e6117c238c8efbf96f Mon Sep 17 00:00:00 2001 From: Tue Date: Tue, 4 Oct 2022 11:42:43 +0700 Subject: [PATCH] build get set null value --- get.go | 7 +++++++ set.go | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/get.go b/get.go index 73de642..f224ad4 100644 --- a/get.go +++ b/get.go @@ -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 +} diff --git a/set.go b/set.go index 0709375..ec44177 100644 --- a/set.go +++ b/set.go @@ -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, + } +} -- 2.34.1