Hacker News new | ask | show | jobs
by shhsshs 1194 days ago
In this case - the thing I personally value in the template version is I don't have to name the parameters and specify them in a separate place. It's especially useful in larger queries.

    var result = await query(
        'SELECT * FROM foo.bar where bar = :baz
          -- 100 more lines of where clauses, CTEs, etc.
        ',
        {baz} // where did I use this again?  I'd need to scroll up.
    );
versus

    var result = await query(
        sql'SELECT * FROM foo.bar where bar = ${baz}
          -- 100 more lines of where clauses, CTEs, etc.
        `);