35 ms·
sql"SOME SQL"; This looks to be a "tagged template": https://basarat.gitbook.io/typescript/future-javascript/template-strings https://basarat.gitbook.io/typesc
by CoffeeDregs 6y ago
sql"SOME SQL";
This looks to be a "tagged template": https://basarat.gitbook.io/typescript/future-javascript/template-strings https://basarat.gitbook.io/typescript/future-javascript/temp.... I'm a TS user but hadn't seen that feature before. AFAICT, the library is using a side-side-side-feature (tagged templates) of TS as the core abstraction [1]. Impressive. Might be a little brittle in the face of significant SQL or query composition?
Anyhow, I'm a heavier-ORM user but that's impressive.
---
[1] https://github.com/Seb-C/kiss-orm/blob/c4b6c9ad2f81337938a9c609b4bc9ef05b08c300/src/Queries/SqlQuery.ts#L10 https://github.com/Seb-C/kiss-orm/blob/c4b6c9ad2f81337938a9c...
- lucideer 6y agoTagged templates are a core feature of JS, not just of TS https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_templates https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- exevp 6y agoNot specific to TS, just one of the modern JS features: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... Scroll down to the part explaining how to use custom tags.
- marton78 6y agoThis is nothing special, it's commonly used e.g. with GraphQL (the `gql` tag).