Skip to content

Commit c3bfc05

Browse files
mbroadstdaprahamian
authored andcommitted
fix: reintroduce support for 2.6 listIndexes
1 parent 0f38c94 commit c3bfc05

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/operations/list_indexes.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const defineAspects = require('./operation').defineAspects;
66
const maxWireVersion = require('../core/utils').maxWireVersion;
77

88
const LIST_INDEXES_WIRE_VERSION = 3;
9+
const SUPPORTS_FIND_COMMAND = 4;
910

1011
class ListIndexesOperation extends CommandOperationV2 {
1112
constructor(collection, options) {
@@ -16,7 +17,8 @@ class ListIndexesOperation extends CommandOperationV2 {
1617
}
1718

1819
execute(server, callback) {
19-
if (maxWireVersion(server) >= LIST_INDEXES_WIRE_VERSION) {
20+
const serverWireVersion = maxWireVersion(server);
21+
if (serverWireVersion >= LIST_INDEXES_WIRE_VERSION) {
2022
const cursor = this.options.batchSize ? { batchSize: this.options.batchSize } : {};
2123
super.executeCommand(
2224
server,
@@ -29,7 +31,18 @@ class ListIndexesOperation extends CommandOperationV2 {
2931

3032
const systemIndexesNS = this.collectionNamespace.withCollection('system.indexes').toString();
3133
const collectionNS = this.collectionNamespace.toString();
32-
super.executeCommand(server, { find: systemIndexesNS, query: { ns: collectionNS } }, callback);
34+
35+
if (serverWireVersion >= SUPPORTS_FIND_COMMAND) {
36+
super.executeCommand(
37+
server,
38+
{ find: systemIndexesNS, query: { ns: collectionNS } },
39+
callback
40+
);
41+
return;
42+
}
43+
44+
// fall back to running a query
45+
server.query(systemIndexesNS, { query: { ns: collectionNS } }, {}, this.options, callback);
3346
}
3447
}
3548

0 commit comments

Comments
 (0)