Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Model.aggregate in 2.0

default discord avatar
sasjumblast year
1

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?

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.