@@ -163,9 +163,7 @@ var Instrumentation = function(core, options, callback) {
163
163
} ;
164
164
165
165
// If we have an error
166
- if ( err
167
- || ( r && r . result && r . result . writeErrors )
168
- || ( r && r . result && r . result . errmsg ) ) {
166
+ if ( err || ( r . result . ok == 0 ) ) {
169
167
command . failure = err || r . result . writeErrors || r . result ;
170
168
self . emit ( 'failed' , command ) ;
171
169
} else {
@@ -245,7 +243,7 @@ var Instrumentation = function(core, options, callback) {
245
243
246
244
// Command name translation
247
245
var commandTranslation = {
248
- '_find' : 'find' , '_getmore' : 'getMore' , '_killcursor' : 'killCursors'
246
+ '_find' : 'find' , '_getmore' : 'getMore' , '_killcursor' : 'killCursors' , '_explain' : 'explain'
249
247
}
250
248
251
249
prototypes . forEach ( function ( proto ) {
@@ -317,6 +315,17 @@ var Instrumentation = function(core, options, callback) {
317
315
// Override method
318
316
if ( cmd . explain ) command . explain = cmd . explain ;
319
317
if ( cmd . exhaust ) command . exhaust = cmd . exhaust ;
318
+
319
+ // If we have a explain flag
320
+ if ( cmd . explain ) {
321
+ // Create fake explain command
322
+ command = {
323
+ explain : command ,
324
+ verbosity : 'allPlansExecution'
325
+ }
326
+ // Set up the _explain name for the command
327
+ x = '_explain' ;
328
+ }
320
329
} else if ( x == '_getmore' ) {
321
330
command = {
322
331
getMore : this . cursorState . cursorId ,
0 commit comments