道具:消耗资源
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose';
|
||||
import { findIndex } from 'underscore';
|
||||
import { BAG } from '../pubUtils/dicParam';
|
||||
import { SearchItemParam } from '../domain/backEndField/search';
|
||||
// const Transaction = require("mongoose-transactions");
|
||||
@@ -70,9 +69,10 @@ export default class Item extends BaseModel {
|
||||
rec = await ItemModel.findOneAndUpdate({ roleId, id }, { $inc: { count: ratio * count } }, { new: true, upsert: true }).lean(lean);
|
||||
}
|
||||
if (!!rec) {
|
||||
let index = findIndex(result,{id})
|
||||
if (!!result[index]) {
|
||||
result[index] = { id: rec.id, count: rec.count, inc: -count }
|
||||
let index = result.findIndex(cur => cur.id == rec.id);
|
||||
if (index != -1) {
|
||||
result[index].count = rec.count;
|
||||
result[index].inc += -count;
|
||||
} else {
|
||||
result.push({ id: rec.id, count: rec.count, inc: -count });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user