Skip to content

Commit

Permalink
Add DB index (#846)
Browse files Browse the repository at this point in the history
Signed-off-by: Lan Xia <[email protected]>
  • Loading branch information
llxia authored Mar 9, 2024
1 parent 88e26f8 commit faa3b1c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions TestResultSummaryService/Database.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { MongoClient, ObjectID } = require('mongodb');
const ArgParser = require('./ArgParser');
const { logger } = require('./Utils');

let db;
(async function () {
Expand Down Expand Up @@ -33,6 +34,22 @@ let db;
// do nothing. The collection may already exist
}
}
const testResultsDB = db.collection('testResults');

const parentIdIndex = await testResultsDB.createIndex({ parentId: 1 });
logger.info('Index created: ', parentIdIndex);
const urlBuildNameBuildNumIndex = await testResultsDB.createIndex({
url: 1,
buildName: 1,
buildNum: 1,
});
logger.info('Index created: ', urlBuildNameBuildNumIndex);

const result = await testResultsDB.listIndexes().toArray();
logger.info('Existing testResults indexes:');
for (const doc of result) {
logger.info(doc);
}
})();

class Database {
Expand Down

0 comments on commit faa3b1c

Please sign in to comment.