添加显示所有武将页面排序
This commit is contained in:
@@ -144,8 +144,12 @@ export default class Hero extends BaseModel {
|
||||
@prop({ required: true, type: EPlace, default: getInitialEplace(), _id: false })
|
||||
ePlace: EPlace[]; // 武将装备引用数组
|
||||
|
||||
public static async findByRole(roleId: string, lean = true) {
|
||||
const heros: HeroType[] = await HeroModel.find({ roleId }).lean(lean);
|
||||
public static async findByRole(roleId: string, sort: { field: string, sortBy: number }[] = []) {
|
||||
let sortParam = {};
|
||||
for(let {field, sortBy} of sort) {
|
||||
sortParam[field] = sortBy;
|
||||
}
|
||||
const heros: HeroType[] = await HeroModel.find({ roleId }).sort(sortParam).lean();
|
||||
return heros;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user