Merge pull request #17222 from strapi/feature/workflow-return-count-in-meta

This commit is contained in:
Marc Roig 2023-07-07 10:56:02 +02:00 committed by GitHub
commit 5f46fc52a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -121,16 +121,15 @@ module.exports = {
);
const { populate, filters, sort } = await sanitizedQuery.read(query);
const workflows = await workflowService.find({
populate,
filters,
sort,
});
const [workflows, workflowCount] = await Promise.all([
workflowService.find({ populate, filters, sort }),
workflowService.count(),
]);
ctx.body = {
data: await mapAsync(workflows, sanitizeOutput),
meta: {
workflowCount: workflows.length,
workflowCount,
},
};
},