tediousjs/tedious-connection-pool

Error: connection.release is not a function

vincebanzon opened this issue · 1 comments

Expected Behavior

I can't get this to work.
I followed the README.md,

Current Behavior

I can't release the connection

        //release the connection back to the pool when finished

        connection.release();

Error Message

TypeError: connection.release is not a function
at Request [as userCallback] (D:\webservice\app.js:158:18)
at Request._this.callback (D:\webservice\node_modules\tedious\lib\request.js:60:27)

Environment

var Connection = require('tedious').Connection;

var ConnectionPool = require('tedious-connection-pool');

var Request = require('tedious').Request;

// follow the rest of README.md
// ...
// my additional code not in README.md which I believe is lacking.


var config = {
  userName: creds.user, // update me
  password: creds.password, // update me
  server: creds.host, // update me
  options: {
    database: creds.options.database,
    encrypt: true,
    rowCollectionOnRequestCompletion : true
  }
}

connection = new Connection(config);
connection.on('connect', function(err){
  if(err){
    console.log("Error connecting to database: ", err)
  }
  else {
    console.log("Connection to Database Success.");
  }
})

Steps to Reproduce (for bugs)

  1. I basically followed the README.md
  2. but connection is not instantiated nor has history on how it was created.
  3. As you can see, I have connection created, but I'm now confused of connectionPool and connection
  4. Due to that, I can't use connection.release.
    connection.release is not a function

Possible Solution

Please add to README.md more information regarding connection and how it has been instantiated.

I saw it now. It is in callback in

pool.acquire((err, connection) => {

}

Now, I need to add this to all of my request.