Hello you used to be able to aggregate to only get the props you need like so
`
const payload = await getPayloadClient();
const model = payload.collections[SolutionsPagesCms.slug].Model;
const solutionsShort = await model.aggregate<{ id: string; slug: string }>([
{
$group: {
_id: { $toString: "$_id" },
slug: { $first: "$slug" }, // Using $first to get the slug of the first document in each group
},
},
]);
`
However I'm not sure how you would do that in 2.0 any ideas?
Have a look at the 2.0 release notes. There is a section about the new way to access the raw model.
Instead of being
payload.collections[myCollectionSlug].Model
, it is now on the adapter like this
payload.db.collections[myCollectionSlug]
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.