1
1
/*!
2
- * Copyright (c) 2020-2023 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2020-2025 Digital Bazaar, Inc. All rights reserved.
3
3
*/
4
4
import { cleanDB , insertRecord } from './helpers.js' ;
5
5
import { mockEntity1 , mockEntity2 , mockEntity3 } from './mock.data.js' ;
@@ -53,10 +53,17 @@ describe('Entities Database Tests', function() {
53
53
executionStats . nReturned . should . equal ( 1 ) ;
54
54
executionStats . totalKeysExamined . should . equal ( 1 ) ;
55
55
executionStats . totalDocsExamined . should . equal ( 1 ) ;
56
- executionStats . executionStages . inputStage . inputStage . stage
57
- . should . equal ( 'IXSCAN' ) ;
58
- executionStats . executionStages . inputStage . inputStage . keyPattern
59
- . should . eql ( { 'entity.internalId' : 1 } ) ;
56
+ const { executionStages : targetStage } = executionStats ;
57
+ // only mongodb 8+ has 'EXPRESS_IXSCAN'
58
+ if ( targetStage . stage === 'EXPRESS_IXSCAN' ) {
59
+ targetStage . keyPattern . should . eql (
60
+ '{ entity.internalId: 1 }' ) ;
61
+ } else {
62
+ targetStage = executionStages . inputStage . inputStage ;
63
+ targetStage . stage . should . equal ( 'IXSCAN' ) ;
64
+ targetStage . keyPattern . should . eql (
65
+ { 'entity.internalId' : 1 } ) ;
66
+ }
60
67
} ) ;
61
68
it ( `is properly indexed for 'entity.internalId' and` +
62
69
`'entity.batchInvalidationCount' in ` +
@@ -81,10 +88,17 @@ describe('Entities Database Tests', function() {
81
88
executionStats . nReturned . should . equal ( 1 ) ;
82
89
executionStats . totalKeysExamined . should . equal ( 1 ) ;
83
90
executionStats . totalDocsExamined . should . equal ( 1 ) ;
84
- executionStats . executionStages . inputStage . inputStage . stage
85
- . should . equal ( 'IXSCAN' ) ;
86
- executionStats . executionStages . inputStage . inputStage . keyPattern
87
- . should . eql ( { 'entity.internalId' : 1 } ) ;
91
+ const { executionStages : targetStage } = executionStats ;
92
+ // only mongodb 8+ has 'EXPRESS_IXSCAN'
93
+ if ( targetStage . stage === 'EXPRESS_IXSCAN' ) {
94
+ targetStage . keyPattern . should . eql (
95
+ '{ entity.internalId: 1 }' ) ;
96
+ } else {
97
+ targetStage = executionStages . inputStage . inputStage ;
98
+ targetStage . stage . should . equal ( 'IXSCAN' ) ;
99
+ targetStage . keyPattern . should . eql (
100
+ { 'entity.internalId' : 1 } ) ;
101
+ }
88
102
} ) ;
89
103
it ( `is properly indexed for 'entity.internalId' and ` +
90
104
`'entity.batchInvalidationCount' in ` +
@@ -132,10 +146,17 @@ describe('Entities Database Tests', function() {
132
146
executionStats . nReturned . should . equal ( 1 ) ;
133
147
executionStats . totalKeysExamined . should . equal ( 1 ) ;
134
148
executionStats . totalDocsExamined . should . equal ( 1 ) ;
135
- executionStats . executionStages . inputStage . inputStage . stage
136
- . should . equal ( 'IXSCAN' ) ;
137
- executionStats . executionStages . inputStage . inputStage . keyPattern
138
- . should . eql ( { 'entity.internalId' : 1 } ) ;
149
+ const { executionStages : targetStage } = executionStats ;
150
+ // only mongodb 8+ has 'EXPRESS_IXSCAN'
151
+ if ( targetStage . stage === 'EXPRESS_IXSCAN' ) {
152
+ targetStage . keyPattern . should . eql (
153
+ '{ entity.internalId: 1 }' ) ;
154
+ } else {
155
+ targetStage = executionStages . inputStage . inputStage ;
156
+ targetStage . stage . should . equal ( 'IXSCAN' ) ;
157
+ targetStage . keyPattern . should . eql (
158
+ { 'entity.internalId' : 1 } ) ;
159
+ }
139
160
} ) ;
140
161
} ) ;
141
162
describe ( 'getCount()' , function ( ) {
0 commit comments