1
- import type { Document } from '.' ;
2
1
import { MongoError } from './error' ;
3
- import type { Server } from './sdam/server' ;
4
- import { maxWireVersion } from './utils' ;
5
2
6
3
/** @public */
7
4
export const ExplainVerbosity = {
@@ -24,13 +21,6 @@ export interface ExplainOptions {
24
21
explain ?: ExplainVerbosityLike ;
25
22
}
26
23
27
- // Minimum server versions which support explain with specific operations
28
- const SUPPORTS_EXPLAIN_WITH_REMOVE = 3 ;
29
- const SUPPORTS_EXPLAIN_WITH_UPDATE = 3 ;
30
- const SUPPORTS_EXPLAIN_WITH_DISTINCT = 4 ;
31
- const SUPPORTS_EXPLAIN_WITH_FIND_AND_MODIFY = 4 ;
32
- const SUPPORTS_EXPLAIN_WITH_MAP_REDUCE = 9 ;
33
-
34
24
/** @internal */
35
25
export class Explain {
36
26
verbosity : keyof typeof ExplainVerbosity ;
@@ -55,22 +45,4 @@ export class Explain {
55
45
56
46
throw new MongoError ( `explain must be one of ${ Object . keys ( ExplainVerbosity ) } or a boolean` ) ;
57
47
}
58
-
59
- /** Checks that the server supports explain on the given operation or command.*/
60
- static explainSupported ( server : Server , op : string | Document ) : boolean {
61
- const wireVersion = maxWireVersion ( server ) ;
62
- if ( op === 'remove' || ( typeof op === 'object' && op . remove ) ) {
63
- return wireVersion >= SUPPORTS_EXPLAIN_WITH_REMOVE ;
64
- } else if ( op === 'update' || ( typeof op === 'object' && op . update ) ) {
65
- return wireVersion >= SUPPORTS_EXPLAIN_WITH_UPDATE ;
66
- } else if ( op === 'distinct' || ( typeof op === 'object' && op . distinct ) ) {
67
- return wireVersion >= SUPPORTS_EXPLAIN_WITH_DISTINCT ;
68
- } else if ( op === 'findAndModify' || ( typeof op === 'object' && op . findAndModify ) ) {
69
- return wireVersion >= SUPPORTS_EXPLAIN_WITH_FIND_AND_MODIFY ;
70
- } else if ( op === 'mapReduce' || ( typeof op === 'object' && op . mapReduce ) ) {
71
- return wireVersion >= SUPPORTS_EXPLAIN_WITH_MAP_REDUCE ;
72
- }
73
-
74
- return false ;
75
- }
76
48
}
0 commit comments