File tree 2 files changed +15
-4
lines changed
2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 2
2
3
3
const Aspect = require ( './operation' ) . Aspect ;
4
4
const defineAspects = require ( './operation' ) . defineAspects ;
5
- const OperationBase = require ( './operation' ) . OperationBase ;
5
+ const OperationBaseV2 = require ( './operation' ) . OperationBaseV2 ;
6
6
const decorateWithCollation = require ( '../utils' ) . decorateWithCollation ;
7
7
const decorateWithReadConcern = require ( '../utils' ) . decorateWithReadConcern ;
8
8
const executeCommand = require ( './db_ops' ) . executeCommand ;
@@ -18,7 +18,7 @@ const resolveReadPreference = require('../utils').resolveReadPreference;
18
18
* @property {object } query The query for filtering the set of documents to which we apply the distinct filter.
19
19
* @property {object } [options] Optional settings. See Collection.prototype.distinct for a list of options.
20
20
*/
21
- class DistinctOperation extends OperationBase {
21
+ class DistinctOperation extends OperationBaseV2 {
22
22
/**
23
23
* Construct a Distinct operation.
24
24
*
@@ -28,7 +28,7 @@ class DistinctOperation extends OperationBase {
28
28
* @param {object } [options] Optional settings. See Collection.prototype.distinct for a list of options.
29
29
*/
30
30
constructor ( collection , key , query , options ) {
31
- super ( options ) ;
31
+ super ( collection , options ) ;
32
32
33
33
this . collection = collection ;
34
34
this . key = key ;
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
+ const ReadPreference = require ( '../core' ) . ReadPreference ;
4
+
3
5
const Aspect = {
4
6
READ_OPERATION : Symbol ( 'READ_OPERATION' ) ,
5
7
SKIP_SESSION : Symbol ( 'SKIP_SESSION' ) ,
@@ -44,6 +46,14 @@ class OperationBase {
44
46
}
45
47
}
46
48
49
+ class OperationBaseV2 extends OperationBase {
50
+ constructor ( parent , options ) {
51
+ super ( options ) ;
52
+
53
+ this . readPreference = parent ? parent . readPreference : ReadPreference . primary ;
54
+ }
55
+ }
56
+
47
57
function defineAspects ( operation , aspects ) {
48
58
if ( ! Array . isArray ( aspects ) && ! ( aspects instanceof Set ) ) {
49
59
aspects = [ aspects ] ;
@@ -59,5 +69,6 @@ function defineAspects(operation, aspects) {
59
69
module . exports = {
60
70
Aspect,
61
71
defineAspects,
62
- OperationBase
72
+ OperationBase,
73
+ OperationBaseV2
63
74
} ;
You can’t perform that action at this time.
0 commit comments