kdhrubo / db2rest

Instant low-code REST DATA API platform for databases. Connect any database, run anywhere.
https://db2rest.com
Apache License 2.0
161 stars 27 forks source link

Load jinjia SQL templates from file system #670

Open kdhrubo opened 3 weeks ago

kdhrubo commented 3 weeks ago

For templatized SQL all templates should be created with Jinjia.

Jinjia for Java - https://github.com/HubSpot/jinjava

Acceptance

  1. Must be able to read from the file system for jar-based deployments.
  2. Must be able to load from docker volumes.
  3. Only one folder with multiple SQL files(jinjia format) to be supported.
kdhrubo commented 3 weeks ago

Example SQL File

SELECT * FROM public.users
WHERE age >= {{ context.params.age }};

The first one uses request parameters.

SELECT * FROM public.users
WHERE id = {{ context.paths.id }};

The second one uses path variables.

SELECT * FROM public.users
WHERE id = {{ context.headers.id }};

The third one uses http header variables.

thadguidry commented 2 weeks ago

I think Pebble might be better option as discussed in Discord thread? dunno.

kdhrubo commented 2 weeks ago

Will check.

ntananh commented 3 days ago

Just for confirm, the API end-point for this feature is: api/v1/sql/<filename>

kdhrubo commented 3 days ago

Yes that's correct.

On Sun, Sep 8, 2024, 5:12 PM Nguyễn Tấn Anh @.***> wrote:

Just for confirm, the API end-point for this feature is: api/v1/sql/

— Reply to this email directly, view it on GitHub https://github.com/kdhrubo/db2rest/issues/670#issuecomment-2336841475, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAISPRAHAGAHL4UNIBB2WLDZVTDULAVCNFSM6AAAAABMYVKPPOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZWHA2DCNBXGU . You are receiving this because you authored the thread.Message ID: @.***>