felixfbecker / node-sql-template-strings

ES6 tagged template strings for prepared SQL statements 📋
ISC License
610 stars 40 forks source link

feat: Add 'concat' method as immutable alternative to 'append' #72

Open cassiozen opened 6 years ago

cassiozen commented 6 years ago

Useful for reusing a base query with multiple different appended statements:

Example:

const baseQuery = SQL`SELECT * FROM books`;

app.get("/", (req, res) => {
  const query = baseQuery.concat(SQL` WHERE id = ${req.params.id}`);
  // Some response
});

References #71

codecov[bot] commented 6 years ago

Codecov Report

Merging #72 into master will not change coverage. The diff coverage is 100%.

@@          Coverage Diff          @@
##           master    #72   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           1      1           
  Lines          35     47   +12     
  Branches        6      9    +3     
=====================================
+ Hits           35     47   +12
Impacted Files Coverage Δ
index.js 100% <100%> (ø) :arrow_up:
skyjur commented 6 years ago

May I suggest alternative solution https://github.com/felixfbecker/node-sql-template-strings/pull/79