-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhooks.go
More file actions
65 lines (54 loc) · 1.63 KB
/
hooks.go
File metadata and controls
65 lines (54 loc) · 1.63 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package norm
import "context"
// BeforeCreate can be implemented by a model to run logic before insert
type BeforeCreate interface {
BeforeCreate(ctx context.Context) error
}
// AfterCreate can be implemented by a model to run logic after insert
type AfterCreate interface {
AfterCreate(ctx context.Context) error
}
// BeforeUpdate can be implemented by a model to run logic before update
type BeforeUpdate interface {
BeforeUpdate(ctx context.Context) error
}
// AfterUpdate can be implemented by a model to run logic after update
type AfterUpdate interface {
AfterUpdate(ctx context.Context) error
}
// BeforeUpsert can be implemented by a model to run logic before upsert
type BeforeUpsert interface {
BeforeUpsert(ctx context.Context) error
}
// AfterUpsert can be implemented by a model to run logic after upsert
type AfterUpsert interface {
AfterUpsert(ctx context.Context) error
}
// Delete hooks
type BeforeDelete interface {
BeforeDelete(ctx context.Context, id any) error
}
type AfterDelete interface {
AfterDelete(ctx context.Context, id any) error
}
// SoftDelete hooks
type BeforeSoftDelete interface {
BeforeSoftDelete(ctx context.Context, id any) error
}
type AfterSoftDelete interface {
AfterSoftDelete(ctx context.Context, id any) error
}
// Restore hooks
type BeforeRestore interface {
BeforeRestore(ctx context.Context, id any) error
}
type AfterRestore interface {
AfterRestore(ctx context.Context, id any) error
}
// PurgeTrashed hooks
type BeforePurgeTrashed interface {
BeforePurgeTrashed(ctx context.Context) error
}
type AfterPurgeTrashed interface {
AfterPurgeTrashed(ctx context.Context, affected int64) error
}