- Aggiunto Filtri

- Finder
This commit is contained in:
Paolo Arena
2021-12-11 00:25:54 +01:00
parent 255982ca0f
commit 3f8a2abd66
5 changed files with 62 additions and 15 deletions

View File

@@ -1,18 +1,24 @@
class CParamsQuery {
constructor(params) {
this.table = params.table;
this.startRow = params.startRow;
this.endRow = params.endRow;
// this.count = params.count;
this.filter = params.filter;
this.filterand = params.filterand;
this.filtersearch = params.filtersearch;
this.filtercustom = params.filtercustom;
this.sortBy = params.sortBy;
this.descending = params.descending;
this.userId = params.userId;
this.codeId = params.codeId;
this.lk_tab = params.lk_tab;
this.af_objId_tab = params.af_objId_tab;
this.lk_LF = params.lk_LF;
this.lk_FF = params.lk_FF;
this.lk_as = params.lk_as;
this.lk_proj = params.lk_proj;
this.lk_col2 = params.lk_col2;
}
}

View File

@@ -99,11 +99,40 @@ MySkillSchema.statics.findAllIdApp = function(idapp) {
};
MySkillSchema.statics.getFieldsForSearch = function() {
return [{field: 'idSkill', type: tools.FieldType.Number}];
return [{field: 'idSkill', type: tools.FieldType.Number}
,{field: 'note', type: tools.FieldType.String}
,{field: 'subTitle', type: tools.FieldType.String}
];
};
MySkillSchema.statics.executeQueryTable = function(idapp, params) {
params.fieldsearch = this.getFieldsForSearch();
const otherparams = {
lk_tab: 'users',
lk_LF: 'userId',
lk_FF: '_id',
lk_as: 'user',
af_objId_tab: 'myId',
lk_proj: {
idSkill: 1,
idStatusSkill: 1,
idCity: 1,
numLevel: 1,
photos: 1,
note: 1,
subTitle: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
},
};
params = { ...params, ...otherparams };
return tools.executeQueryTable(this, idapp, params);
};

View File

@@ -319,9 +319,9 @@ router.post('/settable', authenticate, (req, res) => {
mydata.idapp = req.user.idapp;
if (shared_consts.TABLES_ID_NUMBER.includes(params.table)) {
if (mydata['_id'] === undefined) {
mydata._id = 1;
}
//if (mydata['_id'] === undefined) {
// mydata._id = 1;
//}
} else if (params.table === 'hours') {
} else {

View File

@@ -1106,9 +1106,7 @@ module.exports = {
return (myapp) ? myapp.telegram_key : '';
},
getQueryTable(idapp, params) {
// console.log('idapp', idapp);
// console.table(params);
getQueryTable: function(idapp, params) {
if (typeof params.startRow !== 'number') {
throw new Error('startRow must be number');
@@ -1257,6 +1255,14 @@ module.exports = {
}
if (params.filtercustom) {
filtriadded.push(...params.filtercustom);
}
if (params.filtersearch) {
filtriadded.push(...params.filtersearch);
}
if (filtriadded.length > 0)
query.push({$match: {$and: filtriadded}});
@@ -1340,14 +1346,18 @@ module.exports = {
async executeQueryTable(mythistable, idapp, params) {
let query = this.getQueryTable(idapp, params);
const [ris] = await mythistable.aggregate(query);
try {
const [ris] = await mythistable.aggregate(query);
if (ris) {
// console.table(ris.rows);
// console.log('ROW ', ris.count);
return ({count: ris.count, rows: ris.rows});
} else {
return ({count: 0, rows: []});
if (ris) {
// console.table(ris.rows);
// console.log('ROW ', ris.count);
return ({count: ris.count, rows: ris.rows});
} else {
return ({count: 0, rows: []});
}
} catch (e) {
console.log('error', e);
}
},

View File

@@ -29,6 +29,8 @@ module.exports = {
FILTER_TO_MAKE_MEMBERSHIP_CARD: 524288,
FILTER_MEMBERSHIP_CARD_OK: 1048576,
FILTER_MYSKILL_SKILL: 1,
REPORT_FILT_RESP: 1,
REPORT_FILT_ATTIVITA: 2,