39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import BaseModel from './BaseModel';
|
|
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
|
|
|
/**
|
|
* 战斗记录接口
|
|
*/
|
|
@index({ roleId: 1, battleId: 1 })
|
|
|
|
export default class BattleSweepRecord extends BaseModel {
|
|
@prop({ required: true })
|
|
roleId: string; // 角色 id
|
|
@prop({ required: true })
|
|
roleName: string; // 角色名称
|
|
|
|
@prop({ required: true })
|
|
battleId: number; // 关卡 id
|
|
@prop({ required: true })
|
|
warName: string; // 关卡 名
|
|
@prop({ required: true })
|
|
warType: number; // 关卡 类型
|
|
|
|
@prop({ required: true, default: 0 })
|
|
count: number; // 扫荡次数
|
|
|
|
public static async saveBattleSweepRecordById(roleId: string, battleId: number, params: any, lean = true) {
|
|
const result: BattleSweepRecordType = await BattleSweepRecordModel.findOneAndUpdate({ roleId, battleId }, params, {new: true, upsert: true}).lean(lean);
|
|
return result;
|
|
}
|
|
|
|
public static async deleteAccount(roleId: string) {
|
|
let result = await BattleSweepRecordModel.deleteMany({roleId});
|
|
return result;
|
|
}
|
|
}
|
|
|
|
export const BattleSweepRecordModel = getModelForClass(BattleSweepRecord);
|
|
|
|
export interface BattleSweepRecordType extends Pick<DocumentType<BattleSweepRecord>, keyof BattleSweepRecord>{}
|