2022-10-04 04:27:29 +00:00
|
|
|
package postgresql
|
2022-10-04 04:19:25 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/volatiletech/null/v8"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func SetString(val string) null.String {
|
|
|
|
return null.String{
|
|
|
|
String: val,
|
|
|
|
Valid: true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func SetInt(val int) null.Int {
|
|
|
|
return null.Int{
|
|
|
|
Int: val,
|
|
|
|
Valid: true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-04 08:56:34 +00:00
|
|
|
func SetBool(val bool) (res null.Bool) {
|
2022-10-04 04:19:25 +00:00
|
|
|
return null.Bool{
|
|
|
|
Bool: val,
|
|
|
|
Valid: true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-04 08:56:34 +00:00
|
|
|
func SetTime(val time.Time) (res null.Time) {
|
|
|
|
if val.IsZero() {
|
|
|
|
return
|
|
|
|
}
|
2022-10-04 04:19:25 +00:00
|
|
|
return null.Time{
|
|
|
|
Time: val,
|
|
|
|
Valid: true,
|
|
|
|
}
|
|
|
|
}
|
2022-10-04 04:42:43 +00:00
|
|
|
|
2022-10-04 08:56:34 +00:00
|
|
|
func SetJSON(val []byte) (res null.JSON) {
|
|
|
|
if val == nil {
|
|
|
|
return
|
|
|
|
}
|
2022-10-04 04:42:43 +00:00
|
|
|
return null.JSON{
|
|
|
|
JSON: val,
|
|
|
|
Valid: true,
|
|
|
|
}
|
|
|
|
}
|