Existence

Existence tells us whether or not an item exists.

Existence will return a value of true if there are any items that exists and a value of false if there are no items that exist.

The following example will use the same database tables as before. However, this time we will do an Addon on top of an Addon. First, let's assume there are now two merchant records. Second, let's assume there are two deals, each associated with a different merchant. Last, let's assume we have already created an Addon showing a single item.

Now we will create an Addon on top of the Addon showing the deals of the merchants. This Addon will extend the data by the ledger table. The ledger table is keeping track of what deals are used.

In this example, we will create an Addon to the existing deal_of_merchant Addon.

Create a new Addon, then select the ledger table to add to the response.

In this example, we are adding the ledger table to the response.

Next, we will select how we want the data returned. For this example, we will choose existence. Meaning specifically, whether or not a deal has been used.

In this example, we are returning the data by existence. This will tell us whether or not an item exists. And in this example, that means whether or not a deal has been used.

Then, we will select which fields to connect the ledger table with the deal of merchant Addon. In this example, we have a relationship in the ledger table to the deal table. You can also just think of it like mapping the ledger table to the deal table.

In this example, we are select the table reference of the deal id in the ledger table to map to the Addon of the deal of merchant.

Lastly, we can choose a name and confirm that the Addon is mapped correctly. There is nothing for us to customize because existence is returning a true or false value based on whether or not an item exists.

Once we are finished, the response will look like this.

In this example, we can see the response is being extended. First, by the deal of merchant Addon. The, with the Addon we just created the ledger of deal.

Finally, when we run this API endpoint, we will see the ledger of deal Addon will return us true or false values whether an item exists. In this case, it is telling us based on the data in the ledger table, which deals have been used.

In this example, ledger of deal Addon for the 10% off deal at Zuni Cafe is true. That means this deal has been used. Conversely, the 25% off deal at El Farolito has not been used because the ledger of deal Addon is false.