Count

Returns a count of the number of items available.

In the following example, we will use Addons to return a count of items. It will use the same example data from List of items and Single items. The example will use an Addon to extend the merchant records with a count of the deals available with each record.

​

First, within the Query all Records function we will create and Addon. Then, we will choose the deal table to add to the response.

In this example, we will add the deal table to our response of the merchant records.

Next, we will choose how we want the data returned. For this example, we will return the data by item count.

In this example, we are returning the Addon data with an item count.

Then, we choose the field in the deal database table to map to the merchant table.

In this example, we are using the merchant_id in the deal table to map to the merchant database table.

The last steps are to give the Addon a name, confirm the mapped field and optionally customize the response. However, since this Addon is returning a count, we actually don't have anything to optionally customize for the Addon response.

Once those steps are complete, we will see a preview of how the response of the Query all Records for the merchant table will be extended.

In this example, we can see the response is being extended by the Addon deal_of_merchant. It will return a count of deals available for each merchant.

Finally, once we run this API endpoint, we can see the Addon is returning a count of deals associated with the merchant record.

In this example, the Addon is returning a count of 3. Meaning there are 3 deals available for the merchant Zuni Cafe.