db2rest icon indicating copy to clipboard operation
db2rest copied to clipboard

Load jinjia SQL templates from file system

Open kdhrubo opened this issue 1 year ago • 5 comments

For templatized SQL all templates should be created with Jinjia.

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

Acceptance Tasks:

  • [ ] Must be able to read from the file system for jar-based deployments.
  • [ ] Must be able to load from docker volumes.
  • [ ] Only one folder with multiple SQL files(jinjia format) to be supported.
  • [ ] Update documentation on website https://github.com/9tigerio/db2rest-web/issues/7

kdhrubo avatar Aug 19 '24 22:08 kdhrubo

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.

kdhrubo avatar Aug 19 '24 22:08 kdhrubo

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

thadguidry avatar Aug 27 '24 09:08 thadguidry

Will check.

kdhrubo avatar Aug 27 '24 11:08 kdhrubo

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

ntananh avatar Sep 08 '24 22:09 ntananh

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: @.***>

kdhrubo avatar Sep 08 '24 23:09 kdhrubo