我有一个对象我想插入我MSSQL
数据库的表格中。
根据github上的Seriate docs,这不应该是一个问题。
我的设置如下:
apiRoute.js
module.exports = function(express, schema) {
var apiRoute = express.Router();
apiRoute.post('/test-path', function(req, res) {
schema.test()
.then(function(results) {
res.json(results);
}, function(err) {
res.json(err);
});
});
return apiRoute;
}
schema.js
var sql = require('seriate');
var when = require('when');
var test = function() {
return sql.execute({
query: "select * from @children",
params: {
children: {
val: [
{ id: 1, firstName: "James", middleName: "Paul"},
{ id: 2, firstName: "John", middleName: "Winston" },
{ id: 3, firstName: "George", middleName: "Harold" },
{ id: 4, firstName: "Richard", middleName: "Parkin" }
],
asTable: {
id: sql.INT,
firstName: sql.NVARCHAR(50),
middleName: sql.NVARCHAR(50)
}
}
}
});
}
module.exports = {
test: test
}
当我使用Postman进行测试时,请求会一直持续到最终只是超时。
如果我只是在没有asTable
部分的情况下执行查询:
select 1
它运作得很好。
我错过了什么?
答案 0 :(得分:0)
Have you tried using .step
and this:
result.transaction .commit()
I had the same problem, but when I revised using this method it ran through fine, but you'll need to add a terminary function as well to stop (i.e., callback function, .end, etc.).
Let me know if this doesn't make sense, and I'll post the entire sample code.