初始连接添加军团信息

This commit is contained in:
luying
2021-02-04 15:20:44 +08:00
parent aaeaf87324
commit 86c8cbc2f1
5 changed files with 40 additions and 13 deletions
+2 -2
View File
@@ -145,12 +145,12 @@ export default class Hero extends BaseModel {
@prop({ required: true, type: EPlace, default: getInitialEplace(), _id: false })
ePlace: EPlace[]; // 武将装备引用数组
public static async findByRole(roleId: string, sort: { field: string, sortBy: number }[] = []) {
public static async findByRole(roleId: string, sort: { field: string, sortBy: number }[] = [], select?: string, getters = false) {
let sortParam = {};
for(let {field, sortBy} of sort) {
sortParam[field] = sortBy;
}
const heros: HeroType[] = await HeroModel.find({ roleId }).sort(sortParam).lean();
const heros: HeroType[] = await HeroModel.find({ roleId }).sort(sortParam).select(select).lean({ getters });
return heros;
}