Leon Nguyen Leon Nguyen - 4 months ago 65
Node.js Question

ORM for SQL Server on Node.js

I'm on the look for an ORM mapper for SQL Server on Node.js. Long story short, we have a SQL Server running and now we want to use node.js to build web services pulling data from the database.

Do you know any ORM that supports SQL Server on Node.js?

I know that there is this tedious which can help connect to SQL Server but it does not have ORM.



SQL Server so far hasn't gotten a great deal of support yet in the Node.js community. And, since most of the Node.js ecosystem is community-driven, your options will likely be rather limited.

That's not to say there aren't plans to add support for it; just that not many have achieved it yet. Example: The author of sequelize has stated intent to add support eventually.

For now, if it's enough to get plain Objects with columns as keys, Microsoft's own msnodesql can be a good option with its query() method:

sql.query(conn_str, "SELECT 1 as X, 'ABC', 0x0123456789abcdef ", function (err, results) {


    var buffer = new Buffer('0123456789abcdef', 'hex');
    var expected = [{ 'X': 1, 'Column1': 'ABC', 'Column2': buffer}];

    assert.deepEqual(results, expected, "Results don't match");