generated from sv-tools/go-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsearch_index_view.go
92 lines (81 loc) · 2.16 KB
/
search_index_view.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
84
85
86
87
88
89
90
91
92
package mongoifc
import (
"context"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
// SearchIndexView is an interface for `mongo.SearchIndexView` structure
// Documentation: https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#SearchIndexView
type SearchIndexView interface {
CreateMany(
ctx context.Context,
models []mongo.SearchIndexModel,
opts ...*options.CreateSearchIndexesOptions,
) ([]string, error)
CreateOne(
ctx context.Context,
model mongo.SearchIndexModel,
opts ...*options.CreateSearchIndexesOptions,
) (string, error)
DropOne(
ctx context.Context,
name string,
opts ...*options.DropSearchIndexOptions,
) error
List(
ctx context.Context,
searchIdxOpts *options.SearchIndexesOptions,
opts ...*options.ListSearchIndexesOptions,
) (Cursor, error)
UpdateOne(
ctx context.Context,
name string,
definition interface{},
opts ...*options.UpdateSearchIndexOptions,
) error
}
type searchIndexView struct {
siv *mongo.SearchIndexView
}
func (i *searchIndexView) CreateMany(
ctx context.Context,
models []mongo.SearchIndexModel,
opts ...*options.CreateSearchIndexesOptions,
) ([]string, error) {
return i.siv.CreateMany(ctx, models, opts...)
}
func (i *searchIndexView) CreateOne(
ctx context.Context,
model mongo.SearchIndexModel,
opts ...*options.CreateSearchIndexesOptions,
) (string, error) {
return i.siv.CreateOne(ctx, model, opts...)
}
func (i *searchIndexView) DropOne(
ctx context.Context, name string,
opts ...*options.DropSearchIndexOptions,
) error {
return i.siv.DropOne(ctx, name, opts...)
}
func (i *searchIndexView) List(
ctx context.Context,
searchIdxOpts *options.SearchIndexesOptions,
opts ...*options.ListSearchIndexesOptions,
) (Cursor, error) {
cr, err := i.siv.List(ctx, searchIdxOpts, opts...)
if err != nil {
return nil, err
}
return wrapCursor(cr), nil
}
func (i *searchIndexView) UpdateOne(
ctx context.Context,
name string,
definition interface{},
opts ...*options.UpdateSearchIndexOptions,
) error {
return i.siv.UpdateOne(ctx, name, definition, opts...)
}
func wrapSearchIndexView(siv *mongo.SearchIndexView) SearchIndexView {
return &searchIndexView{siv: siv}
}