[]
        
(Showing Draft Content)

Develop a JavaScript Custom Data Source

Develop a JavaScript Data Source

You can also develop a custom data source with Javascript to connect to data providers available through a web API (e.g. Firebase, MongoDB, FaunaDB, InfluxDB, Airtable, etc.).

Steps to create a Javascript custom data source:

  • Create a Visual Studio Class Project and name it according to the custom provider you want to support.

  • Search NuGet for Gcef.CustomProvider.Native package and install it in the project.

  • Search NuGet for the Jint Javascript engine and install it in the project.

  • Add three resources to the project:

    • A small 16x16 icon for the custom provider to be displayed in Wyn.

    • A large 180x130 icon for the custom provider to be displayed in Wyn.

    • A markdown file named UserGuide.md. When creating data sources based on the custom data source, users can look at the UserGuide to learn how to use the custom data source.

  • Set the **Copy to Output Directory** property in Visual Studio properties for the three resource files to **Copy Always**.

  • Name the main class project class according to your provider and write code to implement the INativeQueryDataProvider interface.

  • Once you are done developing and testing, build the project and publish it to a folder.

  • Zip the published artifacts folder and send it to the Wyn administrator to deploy to Wyn or refer to these steps in the Administrator Guide.

Sample

In the zip file that you can download from the link below, you will find a demo Javascript custom data source code that can be deployed to Wyn. It sends an API request to a fake JSON server from Typicode.com to get random blog posts.


JavascriptProvider.zip

Disclaimer

  • The source code of this data provider is provided as-is. You can modify it to fit your needs. You can also redistribute it without any restrictions.

  • This data provider is a demo provider published by the Wyn team to demonstrate how to create a custom data provider. It is not guaranteed to work in all scenarios. If you have any questions, please contact technical support at experts@wynenterprise.com.

Once deployed to Wyn, this data provider is treated as a Native data provider. It can only be used in the following scenarios:

  • Native Datasets

  • CustomSQLTable in Direct or Cached Datasets

Benefits of Javascript Custom Data Sources

This is just a simple demo, but you are free to add any functionality you need beyond what the basic demo offers. There are many benefits to a Javascript custom data source:

  • It supports paging to get API data through a fixed structure to build a data table.

  • It allows you to configure a special connection string and keep the real database connection information hidden in the Wyn custom data source code.

  • It allows you to configure the parameters so that they can be used not only as database parameters but also as a special configuration for the current provider. You can also have Wyn populate the parameters directly for you.

  • It allows you to execute more actions before or after each execution of the query, such as calling APIs, logging (you can use parameters to record information about the user who executed the current SQL), and more.