1

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?

Nilzone-
  • 2,766
  • 6
  • 35
  • 71

1 Answers1

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.

awilliams
  • 36
  • 7