Skip to content

Commit faa3b1c

Browse files
authored
Add DB index (#846)
Signed-off-by: Lan Xia <[email protected]>
1 parent 88e26f8 commit faa3b1c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

TestResultSummaryService/Database.js

+17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const { MongoClient, ObjectID } = require('mongodb');
22
const ArgParser = require('./ArgParser');
3+
const { logger } = require('./Utils');
34

45
let db;
56
(async function () {
@@ -33,6 +34,22 @@ let db;
3334
// do nothing. The collection may already exist
3435
}
3536
}
37+
const testResultsDB = db.collection('testResults');
38+
39+
const parentIdIndex = await testResultsDB.createIndex({ parentId: 1 });
40+
logger.info('Index created: ', parentIdIndex);
41+
const urlBuildNameBuildNumIndex = await testResultsDB.createIndex({
42+
url: 1,
43+
buildName: 1,
44+
buildNum: 1,
45+
});
46+
logger.info('Index created: ', urlBuildNameBuildNumIndex);
47+
48+
const result = await testResultsDB.listIndexes().toArray();
49+
logger.info('Existing testResults indexes:');
50+
for (const doc of result) {
51+
logger.info(doc);
52+
}
3653
})();
3754

3855
class Database {

0 commit comments

Comments
 (0)