From ee0fdf116c223ed87758ac48547bcc09b3b9544c Mon Sep 17 00:00:00 2001 From: liangtongchuan Date: Sun, 7 May 2023 16:14:10 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(db):=20role=E7=B4=A2=E5=BC=95?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=8C=E5=8E=BB=E6=8E=89=E6=97=A0=E7=B4=A2?= =?UTF-8?q?=E5=BC=95=E7=9A=84sort?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shared/db/Role.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/shared/db/Role.ts b/shared/db/Role.ts index 2d2a32a6a..95f26aea6 100644 --- a/shared/db/Role.ts +++ b/shared/db/Role.ts @@ -105,13 +105,15 @@ export class Teraph { /** * 角色字段接口 */ -@index({ roleId: 1, serverId: 1 }) +@index({ roleId: 1 }) @index({ roleName: 1 }) @index({ towerLv: -1, towerUpTime: 1 }) @index({ topLineupCe: 1, updatedAt: 1 }) @index({ ce: -1 }) @index({ 'userInfo.uid': 1, serverId: 1 }) @index({ loginTime: 1 }) +@index({ serverId: 1, loginTime: 1 }) +@index({ lv: 1, loginTime: 1 }) @index({ createdAt: 1 }) export default class Role extends BaseModel { @@ -667,7 +669,7 @@ export default class Role extends BaseModel { public static async getRecommedList(minLv: number, maxLv: number, time: number) { const result: RoleType[] = await RoleROModel.find({ loginTime: { $gt: time }, lv: { $gte: minLv, $lte: maxLv }, hasInit: true }, { _id: 0 }) .select(ROLE_SELECT.SHOW_FRIEND_APPLY_LIST) - .sort({ quitTime: -1, lv: -1, ce: -1 }) + .sort({ lv: -1, ce: -1 }) .limit(200).lean({ getters: true, virtuals: true }); return result; } @@ -681,7 +683,7 @@ export default class Role extends BaseModel { ] }, { _id: 0 }) .select(ROLE_SELECT.SHOW_FRIEND_APPLY_LIST) - .sort({ quitTime: -1, lv: -1, ce: -1 }) + .sort({ lv: -1, ce: -1 }) .limit(200).lean({ getters: true, virtuals: true }); return result; }