- 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

@@ -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);
}
},