Skip to main content
Forest allows creating new fields on any collection, either computationally, by fetching data on an external API, or based on other data available on the connected data sources. By default, the fields that you create will be read-only, but make them filterable and sortable, and writable by using the relevant methods.

How does it work?

When creating a new field you will need to provide:
FieldDescription
columnTypeType of the new field (any primitive or composite type)
dependenciesList of fields needed from the source records and linked records to run the handler
getValuesHandler which computes the new value for a batch of records
enumValues (optional)When columnType is Enum, you must specify the values that the field will support

Examples

Adding a field by concatenating other fields

This example adds a user.displayName field, which is computed by concatenating the first and last names.

Adding a field that depends on another computed field

This example adds a user.displayName field, then another that capitalizes it.

Adding a field that depends on a many-to-one relationship

We can improve the previous example by adding the city of the user to the display name.

Adding a field that depends on a one-to-many relationship

Let’s add a user.totalSpending field by summing the amount of all orders.

Adding a field fetching data from an API

Let’s imagine that we want to check if the email address of our users is deliverable. We can use a verification API to perform that work.

Performance

When adding many fields, keep in mind that:
  • You should refrain from making queries to external services
    • Use relationships in the dependencies array when that is possible
    • Use batch API calls instead of performing requests one by one inside of the records.map handler
  • Only add fields you need in the dependencies list
    • This will reduce the pressure on your data sources (fewer columns to fetch)
    • And increase the probability of reducing the number of records passed to your handler (records are deduplicated)
  • Do not duplicate code between handlers of different fields: fields can depend on each other (no cycles allowed)