Add a table to a script
By adding a table to your script, you can conveniently store, manage, and manipulate structured data within your scripts.
Prerequisites
-
You have created a new script or imported an existing one.
-
The script is in edit mode. An open lock icon for the script in the Application component pane indicates that you have opened the script and can edit it. If the script is in display mode, right-click the script and select Edit.
Procedure
-
Drag and drop a table from the Reusable components pane into the script in the Application components pane.
-
Right-click a code line in the Script editing pane and select Code Snippets.
Result: The Code Snippets dialog opens. All generated code snippets to perform functions on a table are shown in the entities category.
For example, for the Count function:
await entities.{=contextName}.count({ where: { age: 30 } });
. -
Select Copy.
Result: The selected code snippet for the table is inserted directly into the Script editing pane.
-
Replace the default
{=contextName}
with the name of the table you want the function to be performed for.For example, for the sample table employees, for the Count function:
await entities.employees.count({ where: { age: 30 } });
Results
-
You have added a table to a script using a code snippet to perform specific functions for the selected table in the script.