-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsearch_index_view.go
More file actions
97 lines (86 loc) · 2.66 KB
/
search_index_view.go
File metadata and controls
97 lines (86 loc) · 2.66 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
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
93
94
95
96
97
package mongoifc
import (
"context"
"go.mongodb.org/mongo-driver/v2/mongo"
"go.mongodb.org/mongo-driver/v2/mongo/options"
)
// SearchIndexView is an interface for `mongo.SearchIndexView` structure
// Documentation: https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/mongo#SearchIndexView
type SearchIndexView interface {
CreateMany(
ctx context.Context,
models []mongo.SearchIndexModel,
opts ...options.Lister[options.CreateSearchIndexesOptions],
) ([]string, error)
CreateOne(
ctx context.Context,
model mongo.SearchIndexModel,
opts ...options.Lister[options.CreateSearchIndexesOptions],
) (string, error)
DropOne(
ctx context.Context,
name string,
opts ...options.Lister[options.DropSearchIndexOptions],
) error
List(
ctx context.Context,
searchIdxOpts options.Lister[options.SearchIndexesOptions],
opts ...options.Lister[options.ListSearchIndexesOptions],
) (Cursor, error)
UpdateOne(
ctx context.Context,
name string,
definition any,
opts ...options.Lister[options.UpdateSearchIndexOptions],
) error
}
type searchIndexView struct {
siv *mongo.SearchIndexView
}
// CreateMany is a wrapper for `mongo.SearchIndexView.CreateMany` method
func (i *searchIndexView) CreateMany(
ctx context.Context,
models []mongo.SearchIndexModel,
opts ...options.Lister[options.CreateSearchIndexesOptions],
) ([]string, error) {
return i.siv.CreateMany(ctx, models, opts...)
}
// CreateOne is a wrapper for `mongo.SearchIndexView.CreateOne` method
func (i *searchIndexView) CreateOne(
ctx context.Context,
model mongo.SearchIndexModel,
opts ...options.Lister[options.CreateSearchIndexesOptions],
) (string, error) {
return i.siv.CreateOne(ctx, model, opts...)
}
// DropOne is a wrapper for `mongo.SearchIndexView.DropOne` method
func (i *searchIndexView) DropOne(
ctx context.Context, name string,
opts ...options.Lister[options.DropSearchIndexOptions],
) error {
return i.siv.DropOne(ctx, name, opts...)
}
// List is a wrapper for `mongo.SearchIndexView.List` method
func (i *searchIndexView) List(
ctx context.Context,
searchIdxOpts options.Lister[options.SearchIndexesOptions],
opts ...options.Lister[options.ListSearchIndexesOptions],
) (Cursor, error) {
cr, err := i.siv.List(ctx, searchIdxOpts, opts...)
if err != nil {
return nil, err
}
return wrapCursor(cr), nil
}
// UpdateOne is a wrapper for `mongo.SearchIndexView.UpdateOne` method
func (i *searchIndexView) UpdateOne(
ctx context.Context,
name string,
definition any,
opts ...options.Lister[options.UpdateSearchIndexOptions],
) error {
return i.siv.UpdateOne(ctx, name, definition, opts...)
}
func wrapSearchIndexView(siv *mongo.SearchIndexView) SearchIndexView {
return &searchIndexView{siv: siv}
}