- Permissions table (probably I'll change for others uses)
- Added CDateTime component (to save in the db)... in the component CGridTableRec and for CEventsCalendar
This commit is contained in:
@@ -28,6 +28,8 @@ webpush.setVapidDetails(subject, publicVapidKey, privateVapidKey);
|
||||
|
||||
|
||||
module.exports = {
|
||||
INITDB_FIRSTIME: true,
|
||||
|
||||
TYPE_PROJECT: 1,
|
||||
TYPE_TODO: 2,
|
||||
|
||||
@@ -369,9 +371,28 @@ module.exports = {
|
||||
throw new Error('endRow must be number')
|
||||
}
|
||||
|
||||
const query = [
|
||||
{ $match: Object.assign({ idapp }, params.filter) }
|
||||
];
|
||||
let query = [];
|
||||
if (params.filter && params.fieldsearch) {
|
||||
let myregexp = {};
|
||||
myregexp = new RegExp(params.filter.replace(' ', '|'), "ig");
|
||||
|
||||
const myfilters = [];
|
||||
params.fieldsearch.forEach((field) => {
|
||||
const data = {};
|
||||
data[field] = myregexp;
|
||||
myfilters.push(data);
|
||||
});
|
||||
|
||||
query = [
|
||||
{ $match: { $or: myfilters } },
|
||||
]
|
||||
}
|
||||
if (idapp > 0) {
|
||||
query.push( { $match: { idapp } } );
|
||||
}
|
||||
|
||||
// console.log('QUERYMATCH', query[0].$match.or);
|
||||
// console.log('filter', params.filter);
|
||||
|
||||
if (params.sortBy) {
|
||||
// maybe we want to sort by blog title or something
|
||||
@@ -399,7 +420,10 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
);
|
||||
return query
|
||||
|
||||
console.log('query', query);
|
||||
|
||||
return query;
|
||||
|
||||
},
|
||||
|
||||
@@ -408,10 +432,17 @@ module.exports = {
|
||||
|
||||
return mythistable
|
||||
.aggregate(query)
|
||||
.then(([{ count, rows }]) => {
|
||||
return ({ count, rows })
|
||||
.then(([ris]) => {
|
||||
if (ris) {
|
||||
console.table(ris.rows);
|
||||
console.log('ROW ', ris.count);
|
||||
return ({ count: ris.count, rows: ris.rows })
|
||||
} else {
|
||||
return ({ count: 0, rows: [] })
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
return {
|
||||
count: 0, rows: []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user