Files
ZYZ/shared/db/SearchRecord.ts
2020-12-28 14:42:16 +08:00

39 lines
1.2 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
class SearchTask {
@prop({ required: true })
id: number; // 任务表中的唯一 Id
@prop({ required: true })
taskCode: string; // 服务器生成的任务唯一标识
@prop({ required: true })
startTime: Date; // 任务派遣开始时间
@prop({ required: true })
status: number; // 派遣任务当前状态0-可派遣1-已派遣2-已完成3-已领取
@prop({ required: true, default: [] })
heroes: Array<number> // 派遣武将 hid
}
/**
* 派遣任务记录表
*/
@index({ roleId: 1, type: 1 })
export default class SearchRecord extends BaseModel {
@prop({ required: true })
roleId: string; // 角色 id
@prop({ required: true })
batchCode: string; // 本批派遣任务唯一标识
@prop({ required: true, default: [], _id: false })
tasks: Array<SearchTask>;
public static async deleteAccount(roleId: string) {
let result = await SearchRecordModel.deleteMany({roleId});
return result;
}
}
export const SearchRecordModel = getModelForClass(SearchRecord);
export interface SearchRecordType extends Pick<DocumentType<SearchRecord>, keyof SearchRecord>{};