Node.js 上 SQL Server 的 ORM
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15512673/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ORM for SQL Server on Node.js
提问by L N
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.
我正在为 Node.js 上的 SQL Server 寻找 ORM 映射器。长话短说,我们有一个 SQL Server 正在运行,现在我们想使用 node.js 来构建从数据库中提取数据的 Web 服务。
Do you know any ORM that supports SQL Server on Node.js?
你知道在 Node.js 上支持 SQL Server 的任何 ORM 吗?
I know that there is this tediouswhich can help connect to SQL Server but it does not have ORM.
我知道有一个乏味的东西可以帮助连接到 SQL Server,但它没有 ORM。
Thanks
谢谢
采纳答案by Jonathan Lonowski
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.
到目前为止,SQL Server 还没有在 Node.js 社区中获得大量支持。而且,由于大多数 Node.js 生态系统都是社区驱动的,因此您的选择可能相当有限。
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 sequelizehas stated intent to add support eventually.
这并不是说没有计划增加对它的支持;只是还没有多少人做到了。示例: 的作者sequelize已表示最终打算添加支持。
For now, if it's enough to get plain Objects with columns as keys, Microsoft's own msnodesqlcan be a good option with its query()method:
现在,如果这是足以让普通的Object有作为键列S,微软自己msnodesql可以与一个不错的选择它的query()方法:
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();
});
回答by alesscor
According to sequelize's documentation, ormsupport for sql-serveris available in version 2.0 (released on Feb. 10, 2015, previously added on Dec. 22, 2014's release candidate).
根据sequelize的文档,orm对sql-server 的支持在 2.0 版中可用(于2015年2 月 10 日发布,之前在2014年12 月 22 日的候选发布版本中添加)。
回答by Niall Paterson
回答by Tim Macfarlane
回答by bgerth
I am using BookshelfORM, it has built-in support for MS SQL Server via its dependency on Knex.js, though it's not explicitly listed on the Bookshelf website.
我正在使用BookshelfORM,它通过对Knex.js 的依赖内置了对 MS SQL Server 的支持,尽管 Bookshelf 网站上没有明确列出。
Specify client: 'mssql'on initialization of Bookshelf.
client: 'mssql'在书架初始化时指定。

