lowcoder-org / lowcoder

🔥 🔥 🔥 The Open Source Retool, Tooljet and Appsmith Alternative
https://www.lowcoder.cloud/
GNU Affero General Public License v3.0
689 stars 155 forks source link

[Feat]: Allow Datasource object as module input parameter #647

Open sseide opened 6 months ago

sseide commented 6 months ago

Is your feature request related to a problem? Please describe.

Currently i try to evaluate the possible use of low-coder within our project.

There we have a lot of different runtime environments to build test and run the code (e.g. work / dev / staging / production environment). All environments have their own databases (with different IPs).

Currently there is no way to set a specific database as input parameter to an module for all queries within this module to use this specific datasource. Right now there is only a way to set query objects as input parameter for module.

This might work for table-like displays of data or on single database item displayed in all its glory but it does not work for dashboard like overviews of different data or data aggregations from multiple queries. Within our test example we must set a dozen of different queries (read and write queries) to be able to display the dashboard and allow easy manipulation (e.g. switching things on/off).

Describe the solution you'd like

Please add the possibility to define a data source as input parameter for a code module, not only query objects. This datasource object should be settable for all query objects defined within the module.

This allows an easier reuse of predefined modules containing multiple different queries. With this enhancement we only need to set the correct datasource for the module and all (read/write) queries within the module use this datasource for their work.

This is especial useful if you reuse the module to display the database values for (lets say) "work" and "dev" environment within the same app, therefor reusing the same name of a datasource does not work here

Describe alternatives you've considered

Setting all query objects needed to the module but this results in a unnecessary long list of module input parameter and the need to duplicate queries for different environments (data bases used) that creates a lot of technical debt if only one query is change. Than all duplication of this one query for all databases in all environments must be updated too.

I'm happy to hear some other workarounds to not have to duplicate all queries for all environments.

Additional context

Don't know at the moment but happy to provide if needed

Best regards, S. Seide

sseide commented 6 months ago

I forget - setting the database connection URI as module input parameter does not work too as data sources do not allow an URI like {{myModuleConnectionUri.value}}. There seems to be no variable expansion before using the URI to create the connection pool

placidic commented 6 months ago

I agree that it would be more graceful to allow a data source as an input, however ee are able to do this today ourselves:

What we did is create a module consisting of a dropdown of environments. Each of our environments have their own host name api1.com, API2.com We have mapped to the selection in the dropdown.

We then define our query in the query library where you can parameterize the host name or any other part of the request. We passed the host name as a parameter and construct the query using that value

sseide commented 6 months ago

Thanks for the hint. But i cannot get it working. I tried with a Redis data source type "Regular" and "URI" (but in the end i need URI due to TLS requirement not supported with "Regular" type).

Neither type does support the "{{varname}}" syntax - every time i get an Illegal character in authority at index X error message and the final Uri used contains the "{{ }}" text without interpretation.

Can you describe your solution i but more, or have some code samples or screenshots? Or is it a shortcoming for the datasource used? Redis connection does not support it but other databases?

What i did:

=> The embedded variables were not be replaced.

Thanks in advance