|
@@ -81,6 +81,10 @@ class CrudService extends NafService {
|
|
}
|
|
}
|
|
// 再将数据过滤
|
|
// 再将数据过滤
|
|
if (projection) pipeline.push({ $project: projection });
|
|
if (projection) pipeline.push({ $project: projection });
|
|
|
|
+ else {
|
|
|
|
+ const defaultProject = this.getSelectFalse();
|
|
|
|
+ if (defaultProject)pipeline.push({ $project: defaultProject });
|
|
|
|
+ }
|
|
const rs = await this.model.aggregate(pipeline);
|
|
const rs = await this.model.aggregate(pipeline);
|
|
// const rs = await this.model.find(trimData(condition), projection, { skip, limit, sort }).exec();
|
|
// const rs = await this.model.find(trimData(condition), projection, { skip, limit, sort }).exec();
|
|
return rs;
|
|
return rs;
|
|
@@ -179,6 +183,26 @@ class CrudService extends NafService {
|
|
}
|
|
}
|
|
return filter;
|
|
return filter;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取model的配置
|
|
|
|
+ */
|
|
|
|
+ async getModel() {
|
|
|
|
+ const obj = this.model.prototype.schema.obj;
|
|
|
|
+ return obj;
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 读取model中不显示的字段
|
|
|
|
+ */
|
|
|
|
+ async getSelectFalse() {
|
|
|
|
+ const obj = await this.getModel();
|
|
|
|
+ const project = {};
|
|
|
|
+ for (const k in obj) {
|
|
|
|
+ const v = obj[k];
|
|
|
|
+ if (v && v.select === false) project[k] = 0;
|
|
|
|
+ }
|
|
|
|
+ if (Object.keys(project).length > 0) return project;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
module.exports.CrudService = CrudService;
|
|
module.exports.CrudService = CrudService;
|