Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pagination not working with PK other than "id" #9

Merged
merged 1 commit into from
Dec 4, 2023
Merged

Fix pagination not working with PK other than "id" #9

merged 1 commit into from
Dec 4, 2023

Conversation

gremo
Copy link
Contributor

@gremo gremo commented Dec 3, 2023

When you return the data in getList, you do:

// ...
const aggregateField = meta?.aggregateField ? meta.aggregateField : "id";

const total = await directusClient.request(
    aggregate(resource, {
        query: params,
        aggregate: {
            countDistinct: aggregateField,
        },
    })
);

return {
    data: response,
    total: total[0]?.countDistinct?.id ?? 0,
};

You correctly use aggregateField from meta when calling aggregate but you forgot to use it again in the return statement, so basically pagination won't work with PK other than "id".

This PR solve the issue.

@tspvivek tspvivek merged commit 4b6fd1c into tspvivek:master Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants