Skip to main content

Capturing Data (Write)

This document presumes you have successfully connected to a data source and have a query that can insert/update/delete data. You should also have gone through the basics of using widgets.

The following widgets can be used to capture user inputs in an application

Widgets store their user input in an internal property that can be referenced using javascript.

Example SQL

INSERT INTO users ("name", "createdAt", "gender")
VALUES ({{nameInput.text}}, {{moment().format("YYYY-MM-DD")}},
{{genderDropdown.selectedOptionValue}});

Example Post Body

{
"name": {{nameInput.text}},
"createdDate": {{moment().format('YYYY-MM-DD')}},
"gender": {{genderDropdown.selectedOptionValue}}
}

In the examples above, the text is the internal property of the nameInput widget while selectedOptionValue is the internal property of the genderDropdown widget. The createdDate key is populated with the value of the current date using the moment.js library

Triggering updates

Since write operations are more expensive, the Query should be triggered once all the user data is captured. To do this, you can make use of a Button widget and configure the Query to run in the onClick of the button.

The property pane has an action section where all the interactions that a user can perform with a widget are listed. You can configure the action to be taken when the interaction takes place in this section.

To configure the Query when a button is clicked, select the action in the onClick dropdown.