Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

edge-sql.js how to set connectionString?

var edge = require('edge');

var getProduct = edge.func('sql', function () {/*
    select * from Products 
    where ProductId = @myProductId
*/});

getProduct({ myProductId: 10 }, function (error, result) {
    if (error) throw error;
    console.log(result);
});

This Code works well but I feel uncomfortable with setting the ConnectionString as ENVIROMENT_VARIALBE!

set EDGE_SQL_CONNECTION_STRING=Data Source=localhost;Initial Catalog=Northwind;Integrated Security=True

But I can´t find a different way to do this! Even on GitHub I can´t find another way on how to set ConnectionString! So I wonder is it even possible in OOB edge-sql.js to set the ConnectionString in Code?

like image 517
makim Avatar asked Sep 16 '13 21:09

makim


1 Answers

After looking at the SourceCode of edge-sql, I was able to find out how it works, I wonder why on GitHub it is described with an EnviromentVariable?

Anyway here is the Code to set the ConnectionString in node.js :-)

var edge = require('edge');

var params = {
    connectionString: "Data Source=localhost;Initial Catalog=ITSM_604;Integrated Security=True",
    source: "select top 1 last_name from account_contact"
};

var getContacts = edge.func('sql', params);

getContacts(null, function(error, result){
    if (error) throw error;
    console.log(result);
});
like image 70
makim Avatar answered Oct 09 '22 06:10

makim