edge-sql.js如何设置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); }); 

此代码工作正常,但是我将ConnectionString设置为ENVIROMENT_VARIALBE会让我感觉不舒服!

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

但我找不到一个不同的方式来做到这一点! 即使在GitHub上,我也无法find如何设置ConnectionString的另一种方法! 所以我想知道是甚至有可能在OOB边缘sql.js设置在代码中的ConnectionString?

在查看edge-sql的SourceCode之后,我能够发现它是如何工作的,我想知道为什么在GitHub上用EnviromentVariable来描述它?

无论如何,这里是在Node.js中设置ConnectionString的代码:-)

 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); }); 

很明显,( https://github.com/tjanczuk/edge/issues/65 ),你也可以这样做:

 var mySelect = edge.func('sql', { source: function () {/* select * from Product */}, connectionString: 'your connection string goes here' }); 

我也不喜欢环境variables技术。