-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel_empty.go
83 lines (61 loc) · 1.6 KB
/
model_empty.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package mongoutils
import (
"context"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
)
// EmptyModel only implement model methods
type EmptyModel struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
}
func (EmptyModel) TypeName() string {
return "unspecified"
}
func (EmptyModel) Collection(db *mongo.Database) *mongo.Collection {
panic("please override collection method")
}
func (EmptyModel) Index(db *mongo.Database) error {
return nil
}
func (EmptyModel) Seed(db *mongo.Database) error {
return nil
}
func (EmptyModel) Pipeline() MongoPipeline {
return NewPipe()
}
func (*EmptyModel) FillCreatedAt() {}
func (*EmptyModel) FillUpdatedAt() {}
func (model *EmptyModel) NewId() {
model.ID = primitive.NewObjectID()
}
func (model *EmptyModel) SetID(id primitive.ObjectID) {
model.ID = id
}
func (model EmptyModel) GetID() primitive.ObjectID {
return model.ID
}
func (EmptyModel) IsEditable() bool {
return true
}
func (EmptyModel) IsDeletable() bool {
return false
}
func (*EmptyModel) Cleanup() {}
func (*EmptyModel) OnInsert(ctx context.Context, opt ...MongoOption) error {
return nil
}
func (*EmptyModel) OnUpdate(ctx context.Context, opt ...MongoOption) error {
return nil
}
func (*EmptyModel) OnDelete(ctx context.Context, opt ...MongoOption) error {
return nil
}
func (EmptyModel) OnInserted(ctx context.Context, opt ...MongoOption) error {
return nil
}
func (EmptyModel) OnUpdated(old any, ctx context.Context, opt ...MongoOption) error {
return nil
}
func (EmptyModel) OnDeleted(ctx context.Context, opt ...MongoOption) error {
return nil
}