core: 优化record_main查询速度

This commit is contained in:
undefined committed 2021-09-10 16:50:50 +08:00
1 parent 36fa399518
commit 336432cc4f
3 files changed
+14 -3

No files matched your search

+9
View File
@@ -1,3 +1,4 @@
/* eslint-disable object-curly-newline */
import {
ObjectID, Collection, UpdateQuery,
PushOperator, MatchKeysAndValues, OnlyFieldsOfType,
@@ -232,5 +233,13 @@ bus.on('domain/delete', (domainId) => Promise.all([
RecordModel.coll.updateMany({ pdomain: domainId }, { $set: { docId: -1 } }),
]));
bus.on('app/started', () => {
RecordModel.coll.createIndexes([
{ key: { 'contest.tid': 1, hidden: 1, _id: -1 }, name: 'basic' },
{ key: { 'contest.tid': 1, hidden: 1, uid: 1, _id: -1 }, name: 'withUser' },
{ key: { 'contest.tid': 1, hidden: 1, pid: 1, _id: -1 }, name: 'withProblem' },
]);
});
export default RecordModel;
global.Hydro.model.record = RecordModel;