添加数据库类型别名
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop } from '@typegoose/typegoose';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
|
||||
|
||||
@index({ roleId: 1, battleId: 1 })
|
||||
@@ -28,19 +28,21 @@ export default class RScriptRecord extends BaseModel {
|
||||
update['scriptAfter'] = script;
|
||||
}
|
||||
|
||||
const items = await RScriptRecordModel.findOneAndUpdate({ roleId, battleId }, update, {upsert: true, new: true}).lean(lean);
|
||||
const items: RScriptRecordType = await RScriptRecordModel.findOneAndUpdate({ roleId, battleId }, update, {upsert: true, new: true}).lean(lean);
|
||||
return items;
|
||||
}
|
||||
|
||||
public static async findbyRoleAndBattle(roleId: string, battleId: number, lean = true) {
|
||||
const items = await RScriptRecordModel.findOne({ roleId, battleId }).select('battleId scriptBefore scriptAfter').sort({battleId: 1}).lean(lean);
|
||||
const items: RScriptRecordType = await RScriptRecordModel.findOne({ roleId, battleId }).select('battleId scriptBefore scriptAfter').sort({battleId: 1}).lean(lean);
|
||||
return items;
|
||||
}
|
||||
|
||||
public static async findbyRole(roleId: string, warType: number, lean = true) {
|
||||
const items = await RScriptRecordModel.find({ roleId, warType }).select('battleId scriptBefore scriptAfter').lean(lean);
|
||||
const items: RScriptRecordType[] = await RScriptRecordModel.find({ roleId, warType }).select('battleId scriptBefore scriptAfter').lean(lean);
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
export const RScriptRecordModel = getModelForClass(RScriptRecord);
|
||||
|
||||
export interface RScriptRecordType extends Pick<DocumentType<RScriptRecord>, keyof RScriptRecord>{};
|
||||
Reference in New Issue
Block a user