@@ -43,17 +43,18 @@ type Query struct {
43
43
registry * bsoncodec.Registry
44
44
}
45
45
46
- // Sort is Used to set the sorting rules for the returned results
47
- // Format: "age" or "+age" means to sort the age field in ascending order, "-age" means in descending order
48
- // When multiple sort fields are passed in at the same time, they are arranged in the order in which the fields are passed in.
49
- // For example, {"age", "-name"}, first sort by age in ascending order, then sort by name in descending order
50
-
46
+ // BatchSize sets the value for the BatchSize field.
47
+ // Means the maximum number of documents to be included in each batch returned by the server.
51
48
func (q * Query ) BatchSize (n int64 ) QueryI {
52
49
newQ := q
53
50
newQ .batchSize = & n
54
51
return newQ
55
52
}
56
53
54
+ // Sort is Used to set the sorting rules for the returned results
55
+ // Format: "age" or "+age" means to sort the age field in ascending order, "-age" means in descending order
56
+ // When multiple sort fields are passed in at the same time, they are arranged in the order in which the fields are passed in.
57
+ // For example, {"age", "-name"}, first sort by age in ascending order, then sort by name in descending order
57
58
func (q * Query ) Sort (fields ... string ) QueryI {
58
59
if len (fields ) == 0 {
59
60
// A nil bson.D will not correctly serialize, but this case is no-op
@@ -155,7 +156,6 @@ func (q *Query) All(result interface{}) error {
155
156
}
156
157
}
157
158
opt := options .Find ()
158
-
159
159
if q .sort != nil {
160
160
opt .SetSort (q .sort )
161
161
}
@@ -171,7 +171,6 @@ func (q *Query) All(result interface{}) error {
171
171
if q .hint != nil {
172
172
opt .SetHint (q .hint )
173
173
}
174
-
175
174
if q .batchSize != nil {
176
175
opt .SetBatchSize (int32 (* q .batchSize ))
177
176
}
0 commit comments