From faa3b1c82e93e11aef7fa04f8d15f454e7b9ee87 Mon Sep 17 00:00:00 2001 From: Lan Xia Date: Sat, 9 Mar 2024 07:55:50 -0500 Subject: [PATCH] Add DB index (#846) Signed-off-by: Lan Xia --- TestResultSummaryService/Database.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/TestResultSummaryService/Database.js b/TestResultSummaryService/Database.js index efb2cc6f..92aa3eb7 100644 --- a/TestResultSummaryService/Database.js +++ b/TestResultSummaryService/Database.js @@ -1,5 +1,6 @@ const { MongoClient, ObjectID } = require('mongodb'); const ArgParser = require('./ArgParser'); +const { logger } = require('./Utils'); let db; (async function () { @@ -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 {