添加数据库类型别名
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';
|
||||
|
||||
/**
|
||||
* 战斗记录接口
|
||||
@@ -25,19 +25,21 @@ export default class BattleDrop extends BaseModel {
|
||||
|
||||
|
||||
public static async findByGid(roleId: string, battleId: number, gid: number, lean = true) {
|
||||
const result = await BattleDropModel.findOneAndUpdate({ roleId, battleId, gid}, {}, {new: true, upsert: true}).lean(lean);
|
||||
const result: BattleDropType = await BattleDropModel.findOneAndUpdate({ roleId, battleId, gid}, {}, {new: true, upsert: true}).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async updateByGid(roleId: string, battleId: number, gid: number, params: {getNum: number, allNum: number, getSum: number, allSum: number}, lean = true) {
|
||||
const result = await BattleDropModel.findOneAndUpdate({roleId, battleId, gid}, {$set: params}).lean(lean);
|
||||
const result: BattleDropType = await BattleDropModel.findOneAndUpdate({roleId, battleId, gid}, {$set: params}).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async deleteAccount(roleId: string, lean = true) {
|
||||
let result = await BattleDropModel.deleteMany({roleId}).lean(lean);
|
||||
return result||{};
|
||||
public static async deleteAccount(roleId: string) {
|
||||
let result = await BattleDropModel.deleteMany({roleId});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export const BattleDropModel = getModelForClass(BattleDrop);
|
||||
|
||||
export interface BattleDropType extends Pick<DocumentType<BattleDrop>, keyof BattleDrop>{}
|
||||
Reference in New Issue
Block a user