Skip to main content

DataSource

This documentation describes the use and configuration of the DataSource folder and the files contained within it in the Synergy IDE.

What is a DataSource?

DataSource is a feature supported by the Synergy IDE and allows developers to perform database queries with REST calls. When the project is created, the DataSource folder is created in a classic project format. This folder is an area where users can store database queries.

DataSource Folder Structure

The DataSource folder consists of the following files and folders:

  1. Query Files: Database queries created by users are stored under this folder. Each query is represented as a separate file.

Query File Structure

Each query file can contain the following information:

  1. Query Name: The query file has a name, which should clearly state the purpose of the query (for example: "GetDepartments"). Query Content: The query file contains the database query that is desired to be performed. For example: "SELECT * FROM OSDEPARTMENTS".
  2. Columns: The columns returned as a result of the query and their related data types are stored in the query file. This information provides information about the output of the query. Connection Settings: The query file defines which database to connect to and the connection properties. For example, database type (MSSQL), connection URL, authentication information, and so on.
  3. Cache Settings: If necessary, query results can be stored in the cache. These settings determine the cache duration (in milliseconds) and whether to cache.
  4. Description: A description can be entered for the query file. This description can describe the purpose of the query, its use, or other important information.

Edit a query file

Users can edit existing query files and save changes. For example, it is possible to add a WHERE condition to the end of a query or make other changes. A comparison of these changes with the previously saved file can also be provided.

  1. By selecting the marked icon, the differences between the last saved file and the current file can be seen. The section opened on the left side refers to the last saved file, and the section opened on the right side refers to the current file. When we look at the panel on the right side, a + sign is seen on the 2nd line. The meaning of this sign indicates that a new line has been added in this file compared to the previous record.

Query File Export and Import

The Synergy IDE allows users to export query files and import them into another project. This feature provides an opportunity to easily share and reuse query files. Exported query files are stored as stand-alone files and can be used in other projects.

  1. Export option is selected by right-clicking on the DataSource folder.
  2. In the project to be transferred, the import option is selected by right-clicking on the DataSource folder, then the file with the extension json is selected in the window that opens and imported.

Parameters

Query files support parameters to be used in queries. Parameters are defined within the query in the format {{ParameterName}}. Users can define these parameters in query files and specify their values during querying. This feature makes queries more flexible and dynamic. For parameter usage, parameters are automatically added with the keyword written between double curvy parentheses. Queries are completed by defining default values for the parameters.

Example Usage :

''diff File Name: GetDepartments

Query Content: SELECT * FROM OSDEPARTMENTS WHERE ID = {{DEPARTMENTID}}

Columns:

  • ID: INTEGER
  • CODE: String
  • DESCRIPTION: String

Parameters

  • NAME : DEPARTMENTID, TYPE : STRING, DEFAULT VALUE : 0

Properties:

  • Description: This query returns departments by filtering by ID parameter.
  • Connection : Consulting
  • Timeout : 60
  • Run type : ExecuteDataAdapter
  • Command type : TSQL

Cache:

  • Cache : Yes
  • Frontline type: Memory
  • Cache time: 6000 (ms)
This example performs the GetDepartments query by connecting to the MSSQL database. The columns returned in the result of the query are ID,CODE,DESCRIPTION,..... The **DEPARTMENTID** parameter is used in the query and must be specified during the query. In addition, the results are stored in the cache for 6000 milliseconds.

### Running the Query
1. To run the typed query, srogu is executed by clicking on the **lightning** icon selected in the top panel.

![](https://docsbimser.blob.core.windows.net/imagecontainer/1-d2c204b6-0e95-45f5-bd3a-4f5fbeab2c89.png)