- Added TablesList page

- Added Insert Record empty
This commit is contained in:
Paolo Arena
2019-10-20 01:21:54 +02:00
parent 3424b20e9a
commit 93eae51ab8
16 changed files with 568 additions and 88 deletions

View File

@@ -330,45 +330,8 @@ UserSchema.statics.getUsersListByParams = function (params) {
* @returns {Object} Object -> `{ rows, count }`
*/
UserSchema.statics.queryTable = function (idapp, params) {
const User = this;
if (typeof params.startRow !== 'number') {
throw new Error('startRow must be number')
} else if (typeof params.endRow !== 'number') {
throw new Error('endRow must be number')
}
const query = [
{ $match: Object.assign({ idapp }, params.filter) }
];
if (params.sortBy) {
// maybe we want to sort by blog title or something
const mysort = { $sort: params.sortBy };
// console.log('sortBy', params.sortBy);
// console.table(mysort);
query.push(mysort)
}
query.push(
{ $group: {
_id: null,
// get a count of every result that matches until now
count: { $sum: 1 },
// keep our results for the next operation
results: { $push: '$$ROOT' }
} },
// and finally trim the results to within the range given by start/endRow
{ $project: {
count: 1,
rows: { $slice: ['$results', params.startRow, params.endRow] }
} }
);
return User
.aggregate(query)
.then(([{ count, rows }]) => ({ count, rows }))
UserSchema.statics.executeQueryTable = function (idapp, params) {
return tools.executeQueryTable(this, idapp, params);
};