I have an object I'd like to have inserted into a table in my MSSQL
DB.
According to the Seriate docs on github, this shouldn't be a problem.
My setup looks like this:
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
}
When I test this with Postman, the requests just keeps going until it eventually just times out.
If I just execute a query without the asTable
part:
select 1
It works just fine.
What am I missing?
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 (ie, callback function, .end, etc.).
Let me know if this doesn't make sense, and I'll post the entire sample code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.