We use this (or a similar) library at $job. I have always been curious about how these sql prefixed strings actually work, and this article didn’t answer that so I finally looked it up.
For anyone else who didn’t know, tagged template literals allow making custom tagged template strings that are parses by a function. So about what I expected was happening.
@gajus, great post! Maybe expand a bit on the tagged template part, otherwise this doesn’t seem much different than string substitution at first glance to someone without knowledge of newer js features.
I do have a separate article about that https://contra.com/p/AqZWWoUB-writing-composable-sql-using-java-script
I think that’s the same article.
strings, what wasn’t clear to me was how the sql