In documentation there is a key as defaultSort but its not compatible with 1.5.4 , what will be the alternative
you can't upgrade?
upgrading version will be bit of work , it doesnt seem feasible to upgrade just for a single configuration changes , i was hoping if i could find some alternative
You can pass the
sort
property with your query to have it be sorted by that field. And prepend a dash to reverse that order.
const posts = await payload.find({
collection: "posts",
sort: "-createdAt",
});
Star
Discord
online
Get dedicated engineering support directly from the Payload team.