Adding variable in response of call

Options
Hi guys! When running a query of all records, I'd like to add a variable that counts the number of sub-lists of things I get via doing an inner join.

Example:
List of Makers, inner join with Cars.
We end up with the list of cars by makers.
Now in the API call, I want to sort the list of makers based on the numbers of cars each Maker has. Example: Ford 1000, vs Hyundai 500, vs Tesla 10.

Updating a variable that already exists in a call is automatically called in the APi. However creating a variable isn't part of the response call, and I didn't find myself the way to add it within the response call to be part of the list rather than at the end, as an aggregated variable (1510 rather than within each maker object)

Thanks for the help!

Comments

  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
    Hey ,

    You would do this by first doing a query all records on cars with an output type of aggregate. You would group by maker and sort by count descending.

    This would give you a list of objects where each object is a count and a maker id. You would then use an add-on to turn that maker id into a maker to get the relavent info.

    Hope that helps. Can show you in person if you come to office hours. This is definitely a more advanced request but very doable.