function not recognized while using node-mssql module of node.js

181 views Asked by At

I'm using module node-mssql(0.0.1 the latest version) to access SQL server. I want to use "select top x * from xxxx" so I use codes like:

var queryObj = new node_mssql.Query({
  host: 'x.x.x.x',
  port: 1433,
  username: 'xx',
  password: 'xxx',
  db: 'xxxxx'
});

queryObj.table(table);
queryObj.where(whereSql);
queryObj.limit(limit);
queryObj.order(order);
queryObj.select(function (data) {
    //success
    callback(data, res);
}, function (err, sql) {
    if (err) { //error
        console.log(err);
    }
});

But I got:

TypeError: queryObj.limit is not a function

error!

Since I can found

function Query(config) {
.....................
};
.....................
Query.prototype.limit = function(limit) {
  this.limit = limit;
  return this;
}; 
.....................................
module.exports = Query;       

in source codes of node-mssql, I don't understand why I got this error! Did I need to add somthing eles to make this function work?

BTW, can I add extra functions for the installed module? I try to add function:

Query.prototype.queryStr = function(queryStr) {
  this.queryStr = queryStr;
  return this;
};

But I got similar

TypeError: queryObj.queryStr is not a function

error..........

0

There are 0 answers