点亮科技树
This commit is contained in:
@@ -11,33 +11,33 @@ import { CounterModel } from './Counter';
|
||||
|
||||
export default class Api extends BaseModel {
|
||||
|
||||
@prop({ required: true })
|
||||
apiId: number;
|
||||
@prop({ required: true })
|
||||
apiId: number;
|
||||
|
||||
@prop({ required: true })
|
||||
api: string;
|
||||
@prop({ required: true })
|
||||
api: string;
|
||||
|
||||
@prop({ required: true })
|
||||
name: string;
|
||||
@prop({ required: true })
|
||||
name: string;
|
||||
|
||||
public static async getApi(api: string, lean = true) {
|
||||
let result: ApiType = await ApiModel.findOne({api}).select('apiId api name').lean(lean);
|
||||
return result;
|
||||
}
|
||||
public static async getApi(api: string, lean = true) {
|
||||
let result: ApiType = await ApiModel.findOne({ api }).select('apiId api name').lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async getAllApi(lean = true) {
|
||||
const api: ApiType[] = await ApiModel.find().sort({apiId: 1}).lean(lean);
|
||||
return api;
|
||||
}
|
||||
public static async getAllApi(lean = true) {
|
||||
const api: ApiType[] = await ApiModel.find().sort({ apiId: 1 }).lean(lean);
|
||||
return api;
|
||||
}
|
||||
|
||||
public static async createApi(api: string, name: string, lean = true) {
|
||||
const apiId = await CounterModel.getNewCounter(COUNTER.API);
|
||||
const result: ApiType = await ApiModel.findOneAndUpdate({ apiId }, { $set: { api, name } }, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async createApi(api:string, name: string, lean = true) {
|
||||
const apiId = await CounterModel.getNewCounter(COUNTER.API);
|
||||
const result: ApiType = await ApiModel.findOneAndUpdate({apiId}, {$set:{api, name}}, {upsert: true, new: true}).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const ApiModel = getModelForClass(Api);
|
||||
|
||||
export interface ApiType extends Pick<DocumentType<Api>, keyof Api>{}
|
||||
export interface ApiType extends Pick<DocumentType<Api>, keyof Api> { }
|
||||
|
||||
@@ -42,8 +42,8 @@ export default class Donation extends BaseModel {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async donation(guildCode: string, donateFund: number, report: Report, lean = true) {
|
||||
const result: DonationType = await DonationModel.findOneAndUpdate({ guildCode }, {$inc:{ donateFund, hisDonateFund: donateFund }, $push:{ reports: report}}, {upsert: true, new: true}).lean(lean);
|
||||
public static async donation(guildCode: string, donateFund: number, pushDate: {reports?: Report}, lean = true) {
|
||||
const result: DonationType = await DonationModel.findOneAndUpdate({ guildCode }, {$inc:{ donateFund, hisDonateFund: donateFund }, $push:pushDate}, {upsert: true, new: true}).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user