-
Notifications
You must be signed in to change notification settings - Fork 0
/
deleted_at.go
49 lines (39 loc) · 1003 Bytes
/
deleted_at.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package datatypes
import (
"encoding/json"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"time"
)
type DeletedAt time.Time
func (n DeletedAt) MarshalJSON() ([]byte, error) {
return json.Marshal(time.Time(n))
}
func (n *DeletedAt) UnmarshalJSON(b []byte) error {
return (*time.Time)(n).UnmarshalJSON(b)
}
func (n DeletedAt) MarshalText() ([]byte, error) {
return (time.Time)(n).MarshalText()
}
func (n *DeletedAt) UnmarshalText(b []byte) error {
return (*time.Time)(n).UnmarshalText(b)
}
func (n DeletedAt) String() string {
return (time.Time)(n).String()
}
func (DeletedAt) QueryClauses(f *schema.Field) []clause.Interface {
return []clause.Interface{clause.Where{
Exprs: []clause.Expression{
clause.Eq{
Column: "deleted_at",
Value: "0001-01-01 08:05:43",
},
},
}}
}
func (d DeletedAt) UpdateClauses(f *schema.Field) []clause.Interface {
return d.QueryClauses(f)
}
func (d DeletedAt) DeleteClauses(f *schema.Field) []clause.Interface {
return d.QueryClauses(f)
}