|
@@ -500,11 +500,21 @@ export const getPageSchema = (crowi) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
builder.populateDataToList(User.USER_FIELDS_EXCEPT_CONFIDENTIAL);
|
|
builder.populateDataToList(User.USER_FIELDS_EXCEPT_CONFIDENTIAL);
|
|
|
|
|
+
|
|
|
|
|
+ if (!opt.offset) {
|
|
|
// count
|
|
// count
|
|
|
- const totalCount = await builder.query.exec('count');
|
|
|
|
|
|
|
+ const totalCount = await builder.query.exec('count');
|
|
|
|
|
+
|
|
|
|
|
+ // find
|
|
|
|
|
+ builder.addConditionToPagenate(opt.offset, opt.limit, sortOpt);
|
|
|
|
|
+ const pages = await builder.query.lean().clone().exec('find');
|
|
|
|
|
+ const result = {
|
|
|
|
|
+ pages, totalCount, offset: opt.offset, limit: opt.limit,
|
|
|
|
|
+ };
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // find
|
|
|
|
|
- builder.addConditionToPagenate(opt.offset, opt.limit, sortOpt);
|
|
|
|
|
|
|
+ // Pagination for infinite scroll
|
|
|
const paginationOptions = {
|
|
const paginationOptions = {
|
|
|
lean: true,
|
|
lean: true,
|
|
|
limit: opt.limit,
|
|
limit: opt.limit,
|
|
@@ -513,7 +523,7 @@ export const getPageSchema = (crowi) => {
|
|
|
};
|
|
};
|
|
|
const paginatedPages = await Page.paginate(builder.query.clone(), paginationOptions);
|
|
const paginatedPages = await Page.paginate(builder.query.clone(), paginationOptions);
|
|
|
const result = {
|
|
const result = {
|
|
|
- pages: paginatedPages.docs, totalCount, offset: opt.offset, limit: opt.limit,
|
|
|
|
|
|
|
+ pages: paginatedPages.docs, totalCount: paginatedPages.totalDocs, offset: opt.offset, limit: opt.limit,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
return result;
|
|
return result;
|