@@ -8,10 +8,8 @@ package command
8
8
9
9
import (
10
10
"context"
11
-
12
11
"github.com/mongodb/mongo-go-driver/bson"
13
12
"github.com/mongodb/mongo-go-driver/core/description"
14
- "github.com/mongodb/mongo-go-driver/core/option"
15
13
"github.com/mongodb/mongo-go-driver/core/readconcern"
16
14
"github.com/mongodb/mongo-go-driver/core/readpref"
17
15
"github.com/mongodb/mongo-go-driver/core/session"
@@ -25,7 +23,8 @@ import (
25
23
type Aggregate struct {
26
24
NS Namespace
27
25
Pipeline * bson.Array
28
- Opts []option.AggregateOptioner
26
+ CursorOpts []* bson.Element
27
+ Opts []* bson.Element
29
28
ReadPref * readpref.ReadPref
30
29
WriteConcern * writeconcern.WriteConcern
31
30
ReadConcern * readconcern.ReadConcern
@@ -58,22 +57,14 @@ func (a *Aggregate) encode(desc description.SelectedServer) (*Read, error) {
58
57
command .Append (bson .EC .SubDocument ("cursor" , cursor ))
59
58
60
59
for _ , opt := range a .Opts {
61
- switch t := opt .(type ) {
62
- case nil , option.OptMaxAwaitTime :
63
- continue
64
- case option.OptBatchSize :
65
- if t == 0 && a .HasDollarOut () {
60
+ switch opt .Key () {
61
+ case "batchSize" :
62
+ if opt .Value ().Int32 () == 0 && a .HasDollarOut () {
66
63
continue
67
64
}
68
- err := opt .Option (cursor )
69
- if err != nil {
70
- return nil , err
71
- }
65
+ cursor .Append (opt )
72
66
default :
73
- err := opt .Option (command )
74
- if err != nil {
75
- return nil , err
76
- }
67
+ command .Append (opt )
77
68
}
78
69
}
79
70
@@ -135,19 +126,10 @@ func (a *Aggregate) Decode(desc description.SelectedServer, cb CursorBuilder, wm
135
126
}
136
127
137
128
func (a * Aggregate ) decode (desc description.SelectedServer , cb CursorBuilder , rdr bson.Raw ) * Aggregate {
138
- opts := make ([]option.CursorOptioner , 0 )
139
- for _ , opt := range a .Opts {
140
- curOpt , ok := opt .(option.CursorOptioner )
141
- if ! ok {
142
- continue
143
- }
144
- opts = append (opts , curOpt )
145
- }
146
-
147
129
labels , err := getErrorLabels (& rdr )
148
130
a .err = err
149
131
150
- res , err := cb .BuildCursor (rdr , a .Session , a .Clock , opts ... )
132
+ res , err := cb .BuildCursor (rdr , a .Session , a .Clock , a . CursorOpts ... )
151
133
a .result = res
152
134
if err != nil {
153
135
a .err = Error {Message : err .Error (), Labels : labels }
0 commit comments