@@ -17,6 +17,8 @@ package callback
17
17
import (
18
18
"context"
19
19
20
+ "github.com/chenmingyong0423/go-mongox/v2/internal/hook/model"
21
+
20
22
"github.com/chenmingyong0423/go-mongox/v2/internal/hook/field"
21
23
22
24
"github.com/chenmingyong0423/go-mongox/v2/operation"
@@ -33,30 +35,97 @@ func InitializeCallbacks() *Callback {
33
35
return field .Execute (ctx , opCtx , operation .OpTypeBeforeInsert , opts ... )
34
36
},
35
37
},
38
+ {
39
+ name : "mongox:model" ,
40
+ fn : func (ctx context.Context , opCtx * operation.OpContext , opts ... any ) error {
41
+ return model .Execute (ctx , opCtx , operation .OpTypeBeforeInsert , opts ... )
42
+ },
43
+ },
44
+ },
45
+ afterInsert : []callbackHandler {
46
+ {
47
+ name : "mongox:model" ,
48
+ fn : func (ctx context.Context , opCtx * operation.OpContext , opts ... any ) error {
49
+ return model .Execute (ctx , opCtx , operation .OpTypeAfterInsert , opts ... )
50
+ },
51
+ },
36
52
},
37
- afterInsert : make ([]callbackHandler , 0 ),
38
53
beforeUpdate : []callbackHandler {
39
54
{
40
55
name : "mongox:fieds" ,
41
56
fn : func (ctx context.Context , opCtx * operation.OpContext , opts ... any ) error {
42
57
return field .Execute (ctx , opCtx , operation .OpTypeBeforeUpdate , opts ... )
43
58
},
44
59
},
60
+ {
61
+ name : "mongox:model" ,
62
+ fn : func (ctx context.Context , opCtx * operation.OpContext , opts ... any ) error {
63
+ return model .Execute (ctx , opCtx , operation .OpTypeBeforeUpdate , opts ... )
64
+ },
65
+ },
66
+ },
67
+ afterUpdate : []callbackHandler {
68
+ {
69
+ name : "mongox:model" ,
70
+ fn : func (ctx context.Context , opCtx * operation.OpContext , opts ... any ) error {
71
+ return model .Execute (ctx , opCtx , operation .OpTypeAfterUpdate , opts ... )
72
+ },
73
+ },
74
+ },
75
+ beforeDelete : []callbackHandler {
76
+ {
77
+ name : "mongox:model" ,
78
+ fn : func (ctx context.Context , opCtx * operation.OpContext , opts ... any ) error {
79
+ return model .Execute (ctx , opCtx , operation .OpTypeBeforeDelete , opts ... )
80
+ },
81
+ },
82
+ },
83
+ afterDelete : []callbackHandler {
84
+ {
85
+ name : "mongox:model" ,
86
+ fn : func (ctx context.Context , opCtx * operation.OpContext , opts ... any ) error {
87
+ return model .Execute (ctx , opCtx , operation .OpTypeAfterDelete , opts ... )
88
+ },
89
+ },
45
90
},
46
- afterUpdate : make ([]callbackHandler , 0 ),
47
- beforeDelete : make ([]callbackHandler , 0 ),
48
- afterDelete : make ([]callbackHandler , 0 ),
49
91
beforeUpsert : []callbackHandler {
50
92
{
51
93
name : "mongox:fieds" ,
52
94
fn : func (ctx context.Context , opCtx * operation.OpContext , opts ... any ) error {
53
95
return field .Execute (ctx , opCtx , operation .OpTypeBeforeUpsert , opts ... )
54
96
},
55
97
},
98
+ {
99
+ name : "mongox:model" ,
100
+ fn : func (ctx context.Context , opCtx * operation.OpContext , opts ... any ) error {
101
+ return model .Execute (ctx , opCtx , operation .OpTypeBeforeUpsert , opts ... )
102
+ },
103
+ },
104
+ },
105
+ afterUpsert : []callbackHandler {
106
+ {
107
+ name : "mongox:model" ,
108
+ fn : func (ctx context.Context , opCtx * operation.OpContext , opts ... any ) error {
109
+ return model .Execute (ctx , opCtx , operation .OpTypeAfterUpsert , opts ... )
110
+ },
111
+ },
112
+ },
113
+ beforeFind : []callbackHandler {
114
+ {
115
+ name : "mongox:model" ,
116
+ fn : func (ctx context.Context , opCtx * operation.OpContext , opts ... any ) error {
117
+ return model .Execute (ctx , opCtx , operation .OpTypeBeforeFind , opts ... )
118
+ },
119
+ },
120
+ },
121
+ afterFind : []callbackHandler {
122
+ {
123
+ name : "mongox:model" ,
124
+ fn : func (ctx context.Context , opCtx * operation.OpContext , opts ... any ) error {
125
+ return model .Execute (ctx , opCtx , operation .OpTypeAfterFind , opts ... )
126
+ },
127
+ },
56
128
},
57
- afterUpsert : make ([]callbackHandler , 0 ),
58
- beforeFind : make ([]callbackHandler , 0 ),
59
- afterFind : make ([]callbackHandler , 0 ),
60
129
}
61
130
}
62
131
0 commit comments