In Jigx we use Datasources to represent data coming from any backend system. That could be a REST data source, Salesforce, Azure SQL or Jigx Dynamic data as quick examples of backend data. The sky is the limit with Jigx when it comes to data integration. When you define a Datasource you describe a SQLite sql statement which will retrieve the data into the Jigx datasource. Here is a typical example of a Datasource definition to retrieve employee data from SQL Azure.
Note: Our SQLite Datasource (emp-data) in this instance has been pre-populated using the Jigx Azure SQL provider.
datasources: emp-data: type: datasource.sqlite options: provider: DATA_PROVIDER_LOCAL entities: - entity: emps query: SELECT id, '$.first_name', '$.last_name' , ‘$.job_title , ‘$.salary FROM [emps]
Jigx Datasources are then used in UI Components like a LIST to populate data into a list. Here is an example below which constructs a simple Employee list with data provided by the emp-data Datasource.
data: =@ctx.datasources.emp-data item: type: component.list-item options: title: =@ctx.current.item.first_name & ' ' & @ctx.current.item.last_name
Using the power of Jsonata against a Jigx Datasource
At a technical level a Jigx Datasource is a JSON array of objects. Because Jigx uses that standard, the full power of Jsonata available to search, sum , count and generally “program” anything you can think of against a Jigx Datasource. Here are some simple examples:
- Filter the Datasource so that we only see Employees whose first name = John
data: = @ctx.datasources.emp-data[first_name=’John’]
- Filter the Datasource so that we only see Employees whose last name contains ‘Jon’
data: = @ctx.datasources.emp-data[$contains(last_name, ‘Jon’]
- Sum the salary of all Employees with a Job Title of Manager = $sum(@ctx.datasources.emp-
Make sure you visit https://www.jsonata.org to realize the full power and capabilities of Jsonata. Learn how you can provide powerful capabilities in your solutions with Jsonata.