Skip to content

Commit d47e3a1

Browse files
(DOCS-16562): Fix code for finding NaN indexes to work on Atlas (#5984) (#5999)
1 parent edce7c1 commit d47e3a1

File tree

1 file changed

+32
-31
lines changed

1 file changed

+32
-31
lines changed

source/tutorial/expire-data.txt

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -303,37 +303,39 @@ To avoid problems, either drop or correct any misconfigured TTL indexes.
303303
.. code-block:: javascript
304304

305305
function getNaNIndexes() {
306-
const nan_index = [];
307-
308-
const dbs = db.adminCommand({ listDatabases: 1 }).databases;
309-
310-
dbs.forEach((d) => {
311-
const listCollCursor = db
312-
.getSiblingDB(d.name)
313-
.runCommand({ listCollections: 1 }).cursor;
314-
315-
const collDetails = {
316-
db: listCollCursor.ns.split(".$cmd")[0],
317-
colls: listCollCursor.firstBatch.map((c) => c.name),
318-
};
319-
320-
collDetails.colls.forEach((c) =>
321-
db
322-
.getSiblingDB(collDetails.db)
323-
.getCollection(c)
324-
.getIndexes()
325-
.forEach((entry) => {
326-
if (Object.is(entry.expireAfterSeconds, NaN)) {
327-
nan_index.push({ ns: `${collDetails.db}.${c}`, index: entry });
328-
}
329-
})
330-
);
331-
});
332-
333-
return nan_index;
306+
const nan_index = [];
307+
308+
const dbs = db.adminCommand({ listDatabases: 1 }).databases;
309+
310+
dbs.forEach((d) => {
311+
if (d.name != 'local') {
312+
const listCollCursor = db
313+
.getSiblingDB(d.name)
314+
.runCommand({ listCollections: 1 }).cursor;
315+
316+
const collDetails = {
317+
db: listCollCursor.ns.split(".$cmd")[0],
318+
colls: listCollCursor.firstBatch.map((c) => c.name),
319+
};
320+
321+
collDetails.colls.forEach((c) =>
322+
db
323+
.getSiblingDB(collDetails.db)
324+
.getCollection(c)
325+
.getIndexes()
326+
.forEach((entry) => {
327+
if (Object.is(entry.expireAfterSeconds, NaN)) {
328+
nan_index.push({ ns: `${collDetails.db}.${c}`, index: entry });
329+
}
330+
})
331+
);
332+
}
333+
});
334+
335+
return nan_index;
334336
};
335-
336-
getNaNIndexes();
337+
338+
getNaNIndexes();
337339

338340
.. step:: Correct misconfigured indexes.
339341

@@ -343,4 +345,3 @@ To avoid problems, either drop or correct any misconfigured TTL indexes.
343345
As an alternative, you can :dbcommand:`drop <dropIndexes>` any
344346
misconfigured TTL indexes and recreate them later using the
345347
:dbcommand:`createIndexes` command.
346-

0 commit comments

Comments
 (0)