How can I write a template literal in ECMAScript 6 that will contain backticks(`) in and by itself, (i.e. nested backticks)?
For example:
var query = `
UPDATE packet
SET
`association` = "3485435",
`tagname` = "associated"
`
The reason I need it:
It's quite obvious in my code example above.
I'm trying to build node-mysql queries as Strings
and store them in a variable for passing them to MySQL. The MySQL query syntax requires back ticks for UPDATE
-style queries.
The only way I can have them look neat & tidy is by using template literals, otherwise the queries using regular single-line strings look awful because they end up being very long is some cases.
I also want to avoid terminating lines using
as it's cumbersome.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…