.
This commit is contained in:
parent
4716a4252a
commit
403d7690b4
@ -86,7 +86,7 @@ function setPaginationInfo(totalCount, res) {
|
|||||||
|
|
||||||
if (params.paginate.hasNextPages(count)) {
|
if (params.paginate.hasNextPages(count)) {
|
||||||
const nextPage = params.paginate.href();
|
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);
|
res.set('Pagination-Next-Page', true);
|
||||||
} else {
|
} else {
|
||||||
res.set('Pagination-Next-Page', false);
|
res.set('Pagination-Next-Page', false);
|
||||||
|
|||||||
@ -151,6 +151,11 @@ const generateService = (model, extraMethods = {}, options = defaultOptions) =>
|
|||||||
return defaultService.fetchAssociation(params, context)
|
return defaultService.fetchAssociation(params, context)
|
||||||
} else {
|
} else {
|
||||||
const findOptions = parseParamsToFindOptions(params);
|
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);
|
const result = await model.scope(context.scopes).findAndCountAll(findOptions);
|
||||||
|
|
||||||
if (extraMethods.afterFetchAll) {
|
if (extraMethods.afterFetchAll) {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ routes.get('/speakers',
|
|||||||
PaginateMiddleware.middleware(),
|
PaginateMiddleware.middleware(),
|
||||||
SortMiddleware.middleware({ default: "name" }),
|
SortMiddleware.middleware({ default: "name" }),
|
||||||
speakerController.find({
|
speakerController.find({
|
||||||
scopes: ['defaultScope', 'includeValues'],
|
scopes: ['defaultScope', 'includeValues', 'includeMultimedias'],
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@ const extraMethods = {
|
|||||||
rows = rows.map(speaker => speakerComposer(speaker, context));
|
rows = rows.map(speaker => speakerComposer(speaker, context));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
count: rows.length,
|
count: result.count,
|
||||||
rows: rows
|
rows: rows
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user