adminmate-express-mongoose 1.3.7 → 1.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -13,8 +13,8 @@ module.exports = _conf => {
|
|
|
13
13
|
const inlineActions = req.headers['am-inline-actions'] || [];
|
|
14
14
|
const fieldsToSearchIn = req.query.search_in_fields || [];
|
|
15
15
|
const page = parseInt(req.query.page || 1);
|
|
16
|
-
const
|
|
17
|
-
const defaultOrdering = [ ['_id', '
|
|
16
|
+
const rowsPerPage = parseInt(req.query.rows || 10);
|
|
17
|
+
const defaultOrdering = [ ['_id', 'desc'] ];
|
|
18
18
|
const order = req.query.order || null;
|
|
19
19
|
|
|
20
20
|
const currentModel = fnHelper.getModelObject(modelName);
|
|
@@ -89,8 +89,8 @@ module.exports = _conf => {
|
|
|
89
89
|
.select(fieldsToFetchSafe)
|
|
90
90
|
.populate(fieldsToPopulate)
|
|
91
91
|
.sort(orderSafe)
|
|
92
|
-
.skip(
|
|
93
|
-
.limit(
|
|
92
|
+
.skip(rowsPerPage * (page - 1))
|
|
93
|
+
.limit(rowsPerPage)
|
|
94
94
|
.lean()
|
|
95
95
|
.catch(e => {
|
|
96
96
|
res.status(403).json({ message: e.message });
|
|
@@ -101,7 +101,7 @@ module.exports = _conf => {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
const dataCount = await currentModel.countDocuments(findParams);
|
|
104
|
-
const nbPage = Math.ceil(dataCount /
|
|
104
|
+
const nbPage = Math.ceil(dataCount / rowsPerPage);
|
|
105
105
|
|
|
106
106
|
// Make ref fields appeared as link in the dashboard
|
|
107
107
|
const formattedData = data.map(item => {
|
|
@@ -123,7 +123,8 @@ module.exports = _conf => {
|
|
|
123
123
|
count: dataCount,
|
|
124
124
|
pagination: {
|
|
125
125
|
current: page,
|
|
126
|
-
count: nbPage
|
|
126
|
+
count: nbPage,
|
|
127
|
+
rows_per_page: rowsPerPage
|
|
127
128
|
}
|
|
128
129
|
});
|
|
129
130
|
};
|