Existence
Existence tells us whether or not an item exists.
Last updated
Existence tells us whether or not an item exists.
Last updated
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.
Create a new Addon, then select the ledger table to add 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.
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.
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.
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.