Skip to content

Instantly share code, notes, and snippets.

@vouill
Created April 29, 2019 08:32
Show Gist options
  • Save vouill/c7146a0fe515a5f32528a32a4d7aa1a5 to your computer and use it in GitHub Desktop.
Save vouill/c7146a0fe515a5f32528a32a4d7aa1a5 to your computer and use it in GitHub Desktop.
Preparing SQL queries
// before
db.all(`SELECT * FROM POSTS WHERE ID = ${req.params.id};`, function(
err,
row
) {
res.send(row);
});
// after
const stmt = db.prepare("SELECT * FROM POSTS WHERE ID = ?");
stmt.all(req.params.id, function(err, rows) {
res.send(rows);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment