优化:减少初始以及合成武将时返回的数据

This commit is contained in:
luying
2022-04-07 18:36:46 +08:00
parent f20583125d
commit 3cb5c650e2
13 changed files with 63 additions and 56 deletions

View File

@@ -25,8 +25,8 @@ export default class Item extends BaseModel {
count: number; // 道具数量
public static async findbyRole(roleId: string, lean = true) {
const items: ItemType[] = await ItemModel.find({ roleId, count: {$gte: 0} }).select('id count type').lean(lean);
public static async findbyRole(roleId: string, select = '') {
const items: ItemType[] = await ItemModel.find({ roleId, count: {$gte: 0} }).select(select).lean();
return items;
}

View File

@@ -57,8 +57,8 @@ export default class Jewel extends BaseModel {
@prop({ required: false, type: RandSe, default: [], _id: false })
previewRandSe: RandSe[]; // 强化随机属性预览
public static async findbyRole(roleId: string, lean = true) {
const jewels: JewelType[] = await JewelModel.find({ roleId }).lean(lean);
public static async findbyRole(roleId: string, select = '') {
const jewels: JewelType[] = await JewelModel.find({ roleId }).select(select).lean();
return jewels;
}

View File

@@ -19,8 +19,8 @@ export default class Skin extends BaseModel {
@prop({ required: true, default: 0 })
hid: number; // 原始武将id
public static async findbyRole(roleId: string) {
const rec: SkinType[] = await SkinModel.find({ roleId }, {_id: 0}).select('id skinId skinName hid').lean();
public static async findbyRole(roleId: string, select = '') {
const rec: SkinType[] = await SkinModel.find({ roleId }).select(select).lean();
return rec;
}