后台:添加武将,装备,道具
This commit is contained in:
+24
-1
@@ -82,11 +82,34 @@ export default class Item extends BaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static async deleteAccount(roleId: string) {
|
||||
let result = await ItemModel.deleteMany({ roleId });
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async deletebyRoleAndIds(roleId: string, ids: Array<number>) {
|
||||
const result = await ItemModel.deleteMany({ roleId, id: { $in: ids } });
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async updateCountByRoleAndIds(roleId: string, ids: Array<number>, count: number) {
|
||||
const result: ItemType = await ItemModel.findOneAndUpdate({ roleId, id: { $in: ids } }, {$set: {count}}, {new: true, upsert: true}).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async findByField(field: string, value?: number|string, lean = true) {
|
||||
let searchObj = {};
|
||||
if(field != 'all') {
|
||||
if(field == 'roleName') {
|
||||
searchObj['roleName'] = { $regex: new RegExp(value.toString(), 'i') }
|
||||
} else {
|
||||
searchObj[field] = value;
|
||||
}
|
||||
}
|
||||
//.select('uid tel username')
|
||||
const user: ItemType[] = await ItemModel.find(searchObj).lean(lean);
|
||||
return user;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user