File tree Expand file tree Collapse file tree 6 files changed +25
-21
lines changed Expand file tree Collapse file tree 6 files changed +25
-21
lines changed Original file line number Diff line number Diff line change 6
6
7
7
package options
8
8
9
+ import "time"
10
+
9
11
// CountOptions represents all possible options to the count() function
10
12
type CountOptions struct {
11
- Collation * Collation // Specifies a collation
12
- Hint interface {} // The index to use
13
- Limit * int64 // The maximum number of documents to count
14
- MaxTime * int64 // The maximum amount of time to allow the operation to run
15
- Skip * int64 // The number of documents to skip before counting
13
+ Collation * Collation // Specifies a collation
14
+ Hint interface {} // The index to use
15
+ Limit * int64 // The maximum number of documents to count
16
+ MaxTime * time. Duration // The maximum amount of time to allow the operation to run
17
+ Skip * int64 // The number of documents to skip before counting
16
18
}
17
19
18
20
// Count returns a pointer to a new CountOptions
@@ -40,8 +42,8 @@ func (co *CountOptions) SetLimit(i int64) *CountOptions {
40
42
}
41
43
42
44
// SetMaxTime specifies the maximum amount of time to allow the operation to run
43
- func (co * CountOptions ) SetMaxTime (i int64 ) * CountOptions {
44
- co .MaxTime = & i
45
+ func (co * CountOptions ) SetMaxTime (d time. Duration ) * CountOptions {
46
+ co .MaxTime = & d
45
47
return co
46
48
}
47
49
Original file line number Diff line number Diff line change 6
6
7
7
package options
8
8
9
+ import "time"
10
+
9
11
// DistinctOptions represents all possible options to the distinct() function
10
12
type DistinctOptions struct {
11
- Collation * Collation // Specifies a collation
12
- MaxTime * int64 // The maximum amount of time to allow the operation to run
13
+ Collation * Collation // Specifies a collation
14
+ MaxTime * time. Duration // The maximum amount of time to allow the operation to run
13
15
}
14
16
15
17
// Distinct returns a pointer to a new DistinctOptions
@@ -25,8 +27,8 @@ func (do *DistinctOptions) SetCollation(c *Collation) *DistinctOptions {
25
27
}
26
28
27
29
// SetMaxTime specifies the maximum amount of time to allow the operation to run
28
- func (do * DistinctOptions ) SetMaxTime (i int64 ) * DistinctOptions {
29
- do .MaxTime = & i
30
+ func (do * DistinctOptions ) SetMaxTime (d time. Duration ) * DistinctOptions {
31
+ do .MaxTime = & d
30
32
return do
31
33
}
32
34
Original file line number Diff line number Diff line change 6
6
7
7
package options
8
8
9
+ import "time"
10
+
9
11
// EstimatedDocumentCountOptions represents all possible options to the estimatedDocumentCount() function
10
12
type EstimatedDocumentCountOptions struct {
11
- MaxTime * int64 // The maximum amount of time to allow the operation to run
13
+ MaxTime * time. Duration // The maximum amount of time to allow the operation to run
12
14
}
13
15
14
16
// EstimatedDocumentCount returns a pointer to a new EstimatedDocumentCountOptions
@@ -17,8 +19,8 @@ func EstimatedDocumentCount() *EstimatedDocumentCountOptions {
17
19
}
18
20
19
21
// SetMaxTime specifies the maximum amount of time to allow the operation to run
20
- func (eco * EstimatedDocumentCountOptions ) SetMaxTime (i int64 ) * EstimatedDocumentCountOptions {
21
- eco .MaxTime = & i
22
+ func (eco * EstimatedDocumentCountOptions ) SetMaxTime (d time. Duration ) * EstimatedDocumentCountOptions {
23
+ eco .MaxTime = & d
22
24
return eco
23
25
}
24
26
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ func Count(
68
68
}
69
69
if countOpts .MaxTime != nil {
70
70
cmd .Opts = append (cmd .Opts , bsonx.Elem {
71
- "maxTimeMS" , bsonx .Int64 (int64 (time . Duration ( * countOpts .MaxTime ) / time .Millisecond )),
71
+ "maxTimeMS" , bsonx .Int64 (int64 (* countOpts .MaxTime / time .Millisecond )),
72
72
})
73
73
}
74
74
if countOpts .Skip != nil {
Original file line number Diff line number Diff line change @@ -8,8 +8,6 @@ package driver
8
8
9
9
import (
10
10
"context"
11
- "time"
12
-
13
11
"github.com/mongodb/mongo-go-driver/bson/bsoncodec"
14
12
"github.com/mongodb/mongo-go-driver/x/bsonx"
15
13
@@ -19,6 +17,7 @@ import (
19
17
"github.com/mongodb/mongo-go-driver/x/mongo/driver/uuid"
20
18
"github.com/mongodb/mongo-go-driver/x/network/command"
21
19
"github.com/mongodb/mongo-go-driver/x/network/description"
20
+ "time"
22
21
)
23
22
24
23
// CountDocuments handles the full cycle dispatch and execution of a countDocuments command against the provided
@@ -66,7 +65,7 @@ func CountDocuments(
66
65
// ignore Skip and Limit because we already have these options in the pipeline
67
66
if countOpts .MaxTime != nil {
68
67
cmd .Opts = append (cmd .Opts , bsonx.Elem {
69
- "maxTimeMS" , bsonx .Int64 (int64 (time . Duration ( * countOpts .MaxTime ) / time .Millisecond )),
68
+ "maxTimeMS" , bsonx .Int64 (int64 (* countOpts .MaxTime / time .Millisecond )),
70
69
})
71
70
}
72
71
if countOpts .Collation != nil {
Original file line number Diff line number Diff line change @@ -8,8 +8,6 @@ package driver
8
8
9
9
import (
10
10
"context"
11
- "time"
12
-
13
11
"github.com/mongodb/mongo-go-driver/mongo/options"
14
12
"github.com/mongodb/mongo-go-driver/x/bsonx"
15
13
@@ -19,6 +17,7 @@ import (
19
17
"github.com/mongodb/mongo-go-driver/x/network/command"
20
18
"github.com/mongodb/mongo-go-driver/x/network/description"
21
19
"github.com/mongodb/mongo-go-driver/x/network/result"
20
+ "time"
22
21
)
23
22
24
23
// Distinct handles the full cycle dispatch and execution of a distinct command against the provided
@@ -64,7 +63,7 @@ func Distinct(
64
63
65
64
if distinctOpts .MaxTime != nil {
66
65
cmd .Opts = append (cmd .Opts , bsonx.Elem {
67
- "maxTimeMS" , bsonx .Int64 (int64 (time . Duration ( * distinctOpts .MaxTime ) / time .Millisecond )),
66
+ "maxTimeMS" , bsonx .Int64 (int64 (* distinctOpts .MaxTime / time .Millisecond )),
68
67
})
69
68
}
70
69
if distinctOpts .Collation != nil {
You can’t perform that action at this time.
0 commit comments