ORM for SQL Server on Node.js
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 Object
s 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) {
assert.ifError(err);
var buffer = new Buffer('0123456789abcdef', 'hex');
var expected = [{ 'X': 1, 'Column1': 'ABC', 'Column2': buffer}];
assert.deepEqual(results, expected, "Results don't match");
done();
});
I like Node-odbc, I think some kind of ODBC abstraction is probably best all RDBMS' with NodeJS
According to sequelize's documentation, orm support for sql-server is available in version 2.0 (released on Feb. 10, 2015, previously added on Dec. 22, 2014's release candidate).
I'd suggest taking a look at Prisma. We just announced preview support for SQL Server.
It's an ORM that puts the emphasis on type-safety and developer experience. Unlike traditional ORMs that typically map tables to classes, Prisma maps queries to types (in TypeScript) and returns plain objects from queries.
To get started with Prisma and SQL Server check out this example and start from scratch guide in the docs.