@@ -17,11 +17,6 @@ package callback
1717import (
1818 "context"
1919
20- "github.com/chenmingyong0423/go-mongox/hook/validator"
21-
22- "github.com/chenmingyong0423/go-mongox/hook/model"
23-
24- "github.com/chenmingyong0423/go-mongox/hook/field"
2520 "github.com/chenmingyong0423/go-mongox/operation"
2621)
2722
@@ -31,75 +26,16 @@ var Callbacks = initializeCallbacks()
3126
3227func initializeCallbacks () * Callback {
3328 return & Callback {
34- beforeInsert : []callbackHandler {
35- {
36- name : "mongox:default_field" ,
37- fn : func (ctx context.Context , opCtx * operation.OpContext , opts ... any ) error {
38- return field .Execute (ctx , opCtx , operation .OpTypeBeforeInsert , opts ... )
39- },
40- },
41- {
42- name : "mongox:model" ,
43- fn : func (ctx context.Context , opCtx * operation.OpContext , opts ... any ) error {
44- return model .Execute (ctx , opCtx , operation .OpTypeBeforeInsert , opts ... )
45- },
46- },
47- {
48- name : "mongox:validation" ,
49- fn : func (ctx context.Context , opCtx * operation.OpContext , opts ... any ) error {
50- return validator .Execute (ctx , opCtx , operation .OpTypeBeforeInsert , opts ... )
51- },
52- },
53- },
54- afterInsert : []callbackHandler {
55- {
56- name : "mongox:model" ,
57- fn : func (ctx context.Context , opCtx * operation.OpContext , opts ... any ) error {
58- return model .Execute (ctx , opCtx , operation .OpTypeAfterInsert , opts ... )
59- },
60- },
61- },
29+ beforeInsert : make ([]callbackHandler , 0 ),
30+ afterInsert : make ([]callbackHandler , 0 ),
6231 beforeUpdate : make ([]callbackHandler , 0 ),
6332 afterUpdate : make ([]callbackHandler , 0 ),
6433 beforeDelete : make ([]callbackHandler , 0 ),
6534 afterDelete : make ([]callbackHandler , 0 ),
66- beforeUpsert : []callbackHandler {
67- {
68- name : "mongox:default_field" ,
69- fn : func (ctx context.Context , opCtx * operation.OpContext , opts ... any ) error {
70- return field .Execute (ctx , opCtx , operation .OpTypeBeforeUpsert , opts ... )
71- },
72- },
73- {
74- name : "mongox:model" ,
75- fn : func (ctx context.Context , opCtx * operation.OpContext , opts ... any ) error {
76- return model .Execute (ctx , opCtx , operation .OpTypeBeforeUpsert , opts ... )
77- },
78- },
79- {
80- name : "mongox:validation" ,
81- fn : func (ctx context.Context , opCtx * operation.OpContext , opts ... any ) error {
82- return validator .Execute (ctx , opCtx , operation .OpTypeBeforeUpsert , opts ... )
83- },
84- },
85- },
86- afterUpsert : []callbackHandler {
87- {
88- name : "mongox:model" ,
89- fn : func (ctx context.Context , opCtx * operation.OpContext , opts ... any ) error {
90- return model .Execute (ctx , opCtx , operation .OpTypeAfterUpsert , opts ... )
91- },
92- },
93- },
94- beforeFind : make ([]callbackHandler , 0 ),
95- afterFind : []callbackHandler {
96- {
97- name : "mongox:model" ,
98- fn : func (ctx context.Context , opCtx * operation.OpContext , opts ... any ) error {
99- return model .Execute (ctx , opCtx , operation .OpTypeAfterFind , opts ... )
100- },
101- },
102- },
35+ beforeUpsert : make ([]callbackHandler , 0 ),
36+ afterUpsert : make ([]callbackHandler , 0 ),
37+ beforeFind : make ([]callbackHandler , 0 ),
38+ afterFind : make ([]callbackHandler , 0 ),
10339 }
10440}
10541
0 commit comments