I'm currently using Node.js with Edge.js to insert hardcoded values into a SQL database:
var insertUser = edge.func('sql', function () {/*
INSERT INTO dbo.Newsletter (Email, Active, DateCreated, DateUpdated, Deleted)
VALUES ('test2@test.com','1','2014-01-01 00:00:00','2014-01-01 00:00:00','0')
*/});
This works correctly.
However, I'd like the values to be previously-defined JS variables, not hardcoded. So if I have defined this variable:
var emailAddress = document.getElementById('emailInput').value;
I would like to insert it in place of the hardcoded email address (problem code below):
var insertUser = edge.func('sql', function () {/*
INSERT INTO dbo.Newsletter (Email, Active, DateCreated, DateUpdated, Deleted)
VALUES ('emailAddress','1','2014-01-01 00:00:00','2014-01-01 00:00:00','0')
*/});
The above syntax (and various variations of) doesn't work - is it possible at all to insert JS variables in SQL with Node/Edge? Many thanks in advance...
You can use named parameters in your function like this:
Pass it an object with parameters like this: