Object fields introduced with v15 allows unstructured data bases, similar to schemaless database (NoSQL). 4D v16 goes a big step further. Get a dynamic structure for unstructured data… Confused?
Imagine you use an object field to allow your customers to store custom data, where they can create their own fields. This works well and is one of the most interesting reasons for using an object field. The problem is, how to allow your customer to query this unstructured data? You don’t know which ‘fields’ they used, you cannot build a query editor on top or offer a drop down with used values.
With 4D v16 it is now possible using the two new commands DISTINCT ATTRIBUTE PATHS and DISTINCT ATTRIBUTE VALUES.
- If you want to know all the existing attributes your user could have entered, in order to display them in a popup for example, you can use the DISTINCT ATTRIBUTE PATHS command. This command returns the list of distinct paths found in your indexed object field for the current selection.
- You can also use the DISTINCT ATTRIBUTE VALUES command if you want to know all the existing and non-repeated values in a defined path in order to present them, for example, in a list. This command returns the distinct values coming from a defined path in your indexed object field for the current selection.
In addition, standard mathematical functions have been upgraded so that they can be used with object fields:
- Sum
- Min
- Max
- Average
Example
If you want to see an example, please take a look at this example.
For more details, please refer to the 4D v16 documentation, in the following articles: