Skip to content

Commit e53a84a

Browse files
(DOCS-16562): Fix code for finding NaN indexes to work on Atlas (#5984) (#5998)
1 parent bd1ede9 commit e53a84a

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
@@ -299,37 +299,39 @@ To avoid problems, either drop or correct any misconfigured TTL indexes.
299299
.. code-block:: javascript
300300

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

334336
.. step:: Correct misconfigured indexes.
335337

@@ -339,4 +341,3 @@ To avoid problems, either drop or correct any misconfigured TTL indexes.
339341
As an alternative, you can :dbcommand:`drop <dropIndexes>` any
340342
misconfigured TTL indexes and recreate them later using the
341343
:dbcommand:`createIndexes` command.
342-

0 commit comments

Comments
 (0)