-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdistinct_result.go
More file actions
37 lines (30 loc) · 919 Bytes
/
distinct_result.go
File metadata and controls
37 lines (30 loc) · 919 Bytes
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
package mongoifc
import (
"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo"
)
// DistinctResult is an interface for `mongo.DistinctResult` structure
// Documentation: https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/mongo#DistinctResult
type DistinctResult interface {
Decode(v any) error
Err() error
Raw() (bson.RawArray, error)
}
type distinctResult struct {
dr *mongo.DistinctResult
}
// Decode is a wrapper for `mongo.DistinctResult.Decode` method
func (s *distinctResult) Decode(v any) error {
return s.dr.Decode(v)
}
// Raw is a wrapper for `mongo.DistinctResult.Raw` method
func (s *distinctResult) Raw() (bson.RawArray, error) {
return s.dr.Raw()
}
// Err is a wrapper for `mongo.DistinctResult.Err` method
func (s *distinctResult) Err() error {
return s.dr.Err()
}
func wrapDistinctResult(dr *mongo.DistinctResult) DistinctResult {
return &distinctResult{dr: dr}
}