Relational Databases
Integrating Form.io with relational databases
While Form.io forms and resources are one way an application may collect and store data, many customers use relational databases such as SQL to store data used within their application.
in many instances, customers want to synchronize data between a DB and Form.io. For example, they may want to pull information from a DB to populate choices in a select box. Alternatively, they may want to send submission data directly to their DB where it is consumed elsewhere in their application.
Using Form.io with an external database
There are several methods of working with relational databases and Form.io depending on the specific requirements of the application.
Webhooks
Webhooks can be used to synchronize data from Form submissions to a SQL database. Webhooks are configurable Form.io Actions that are fired upon form submission and make a call to an external API endpoint. By configuring the payload to contain submission data, it can be shuttled into other applications or databases through the application or middleware behind that API endpoint.
This approach is useful for synchronizing data with an external database that serves as the source-of-truth for the application.
Custom API Layer
Instead of connecting Form.io directly to a SQL database, a custom backend service (Node.js, Python, etc.) can be used to communicate between Form.io and the SQL DB. Such a service would generally:
Listen for Form submissions (via webhooks or API calls).
Transform the submission data as needed.
Store the data in the SQL database.
Fetch data from the SQL when needed and provide it to the Form.io front end.
This approach keeps the SQL database structure independent from the Form.io schema while also maintaining data synchronization.
Use Form.io Data Sources
A Form.io Resource can be used to pull data from an external SQL database if that DB is exposed via an API (Express.js, Django, etc.).
This allows a form to dynamically present or use existing external data from the DB.
For additional information on pulling external data into a Form.io resource, refer to the Data Source Component documentation.
The Form.io Server SDK
For greater control when running a deployed Form.io instance, the backend may be modified to support direct SQL database integration.
This may be appropriate when a high degree of customization is required, but involves a significant degree of novel development.
Last updated
Was this helpful?