This commit is contained in:
David Arranz 2019-07-31 12:40:36 +02:00
parent 4716a4252a
commit 403d7690b4
4 changed files with 8 additions and 3 deletions

View File

@ -86,7 +86,7 @@ function setPaginationInfo(totalCount, res) {
if (params.paginate.hasNextPages(count)) {
const nextPage = params.paginate.href();
res.set('Link', nextPage + '; rel=next');
res.set('Link-Next-Page', nextPage + '; rel=next');
res.set('Pagination-Next-Page', true);
} else {
res.set('Pagination-Next-Page', false);

View File

@ -151,6 +151,11 @@ const generateService = (model, extraMethods = {}, options = defaultOptions) =>
return defaultService.fetchAssociation(params, context)
} else {
const findOptions = parseParamsToFindOptions(params);
// Necesario para el cálculo del count
// https://github.com/sequelize/sequelize/issues/10557
findOptions.distinct = true;
const result = await model.scope(context.scopes).findAndCountAll(findOptions);
if (extraMethods.afterFetchAll) {

View File

@ -23,7 +23,7 @@ routes.get('/speakers',
PaginateMiddleware.middleware(),
SortMiddleware.middleware({ default: "name" }),
speakerController.find({
scopes: ['defaultScope', 'includeValues'],
scopes: ['defaultScope', 'includeValues', 'includeMultimedias'],
})
);

View File

@ -18,7 +18,7 @@ const extraMethods = {
rows = rows.map(speaker => speakerComposer(speaker, context));
return {
count: rows.length,
count: result.count,
rows: rows
}
},