Revert "✨ feat(db): item表内查询操作改为只读节点"
This reverts commit 0f46c039303b8f21d8f1e7ba79d929270dde0bab.
This commit is contained in:
@@ -24,27 +24,27 @@ export default class Item extends BaseModel {
|
||||
|
||||
|
||||
public static async findbyRole(roleId: string, select = '') {
|
||||
const items: ItemType[] = await ItemROModel.find({ roleId, count: {$gte: 0} }).select(select).lean();
|
||||
const items: ItemType[] = await ItemModel.find({ roleId, count: {$gte: 0} }).select(select).lean();
|
||||
return items;
|
||||
}
|
||||
|
||||
public static async findbyRoleAndIds(roleId: string, ids: Array<number>, lean = true) {
|
||||
const items: ItemType[] = await ItemROModel.find({ roleId, id: { $in: ids }, count: {$gte: 0} }).select('id count type').lean(lean);
|
||||
const items: ItemType[] = await ItemModel.find({ roleId, id: { $in: ids }, count: {$gte: 0} }).select('id count type').lean(lean);
|
||||
return items;
|
||||
}
|
||||
|
||||
public static async findByRoleAndType(roleId: string, type: number, lean = true) {
|
||||
const items: ItemType[] = await ItemROModel.find({ roleId, type }).select('id count type').sort({ id: 1 }).lean(lean);
|
||||
const items: ItemType[] = await ItemModel.find({ roleId, type }).select('id count type').sort({ id: 1 }).lean(lean);
|
||||
return items;
|
||||
}
|
||||
|
||||
public static async findbyRoleAndGidAndCount(roleId: string, id: number, count: number, lean = true) {
|
||||
const items: ItemType = await ItemROModel.findOne({ roleId, id, count: { $gte: count } }).select('id count type').lean(lean);
|
||||
const items: ItemType = await ItemModel.findOne({ roleId, id, count: { $gte: count } }).select('id count type').lean(lean);
|
||||
return items;
|
||||
}
|
||||
|
||||
public static async findbyRoleAndGid(roleId: string, id: number, lean = true) {
|
||||
const items: ItemType = await ItemROModel.findOne({ roleId, id }).select('id count type').lean(lean);
|
||||
const items: ItemType = await ItemModel.findOne({ roleId, id }).select('id count type').lean(lean);
|
||||
return items;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ export default class Item extends BaseModel {
|
||||
sort[sortField] = -1;
|
||||
}
|
||||
}
|
||||
const result: ItemType[] = await ItemROModel.find(searchObj).limit(pageSize).skip((page - 1) * pageSize).sort(sort).select('-_id -__v -createdAt -updatedAt').lean({ getters: true, virtuals: true });
|
||||
const result: ItemType[] = await ItemModel.find(searchObj).limit(pageSize).skip((page - 1) * pageSize).sort(sort).select('-_id -__v -createdAt -updatedAt').lean({ getters: true, virtuals: true });
|
||||
return result;
|
||||
|
||||
}
|
||||
@@ -133,7 +133,7 @@ export default class Item extends BaseModel {
|
||||
public static async countByCondition(form: SearchItemParam = {}) {
|
||||
|
||||
let searchObj = this.getSearchObj(form);
|
||||
const result = await ItemROModel.count(searchObj);
|
||||
const result = await ItemModel.count(searchObj);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user