How do I flatten my data?

The configuration of fields to flatten occurs on the tables themselves and not in the data source. After the initial collection, you can go to the Tables screen and click on the relevant table. This will list its columns and allow you to make any desired changes, including flattening.

Example

Assume you have a users collection with a field named name that holds your nested object: {first: 'xxx', last:'yyy'}. By default, the platform creates two tables (users and users_name), one for the main (top level) data and another for the nested data under the field name. To flatten this nested data into the main (parent) table, you would take the following steps:

  1. Go to the main table on the Tables screen.
  2. Click the name field and choose Flatten.
  3. Once you collect the data again the nested data flattens into the main table.

Notes

Be aware of the following:

  • The changes won’t affect existing data. Only future collections of data will use the new configuration.

  • If the field you are looking for does not exist in the main table, you must create one. The table name and column will depend on your specific data model. Our example above would use the following statement:

    ALTER TABLE "users" add column "name" varchar(256);