如何使用 Sequelize 调用 MSSQL 存储过程? [英] How to call a MSSQL Stored Procedure using Sequelize?
本文介绍了如何使用 Sequelize 调用 MSSQL 存储过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在努力使用 Sequelize 调用 MS SQL 存储过程.这就是我通常从 SSMS 调用存储过程的方式
I am struggling with calling a MS SQL Stored Proc using Sequelize. This is how i normally call the stored proc from SSMS
USE [MYDB]
GO
DECLARE @return_value int
EXEC @return_value = [dbo].[GetThings_ByLocation]
@BeginDate = N'2016-06-23',
@EndDate = N'2016-07-09',
@LocationID = NULL
SELECT 'Return Value' = @return_value
GO
我将如何使用 sequelize 进行此调用?
How would i make this call using sequelize?
推荐答案
Sequelize 使用 npm 包 Tedious (https://www.npmjs.com/package/tedious) 使用 MS SQL.连接数据库和其他的一样.
Sequelize uses npm package Tedious (https://www.npmjs.com/package/tedious) to work with MS SQL. Connecting to the database is the same as others.
您可以使用原始查询从存储过程中获取结果.
You can use raw query to get results from stored procedures.
sequelize.query('GetThings_ByLocation @BeginDate=\'2016-08-01\', @EndDate=\'2016-08-07\', @LocationID=NULL;')
.then(function(result) {
console.log('RESULT', result);
})
.error(function(err) {
console.log(err);
});
这篇关于如何使用 Sequelize 调用 MSSQL 存储过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文