Error occurred while inserting node-mssql connection continuously

  node.js, question

I am using node.js to connect mssql. the node-mssql used is encapsulated by the following method. a single test has no problem, but when performing continuous insertion, only the last one can be inserted normally. the error prompt: Connection is closed. after searching for half a day, I found that this writing style is quick example with one global connection written on the official document. thus, only one global connection is established. the previous operation is not completed, and the connection is interrupted by the following connection, so there is an error? However, the configuration of pool is also provided in the connection configuration of this library! Where am I wrong and how should I do it? Thank you!

var mssql = require('mssql');
 var options = {
 server: config.server,
 port: config.port,
 user: config.user,
 password: config.password,
 database: config.database,
 pool: {
 max: 10,
 min: 2,
 idleTimeoutMillis: 30000
 bracket
 bracket
 ...
 function query(sql,params){
 return new Promise(function(fulfill, reject) {
 mssql.connect(options, function(err) {
 console.dir(arguments)
 if(err){
 reject({err:err.message})
 logger.error(err.message)
 }else{
 let sqlReq = new mssql.Request();
 if(params){
 let ps = Object.keys(params);
 for(let i = 0;   i < ps.length;  I plus)
 sqlReq.input(ps[i],params[ps[i]])
 bracket
 bracket
 sqlReq.query(sql, function(error, result) {
 if (error) {
 reject({err:error.message});
 Logger.error(error.message plus 'sqlis:' plus sql)
 } else {
 fulfill(result);
 logger.debug(sql)
 bracket
 });
 bracket
 });
 });

The problem has been solved. The document on node-mssql is incomplete. Carefully read the official document. new sql.Connection has a return parameter. This parameter is used as the new sql.request () parameter. It is good!

var connection = new sql.Connection(config, function(err) {
 // ... error checks
 var request = new sql.Request(connection);   // or: var request =  connection.request();
 request.query('select 1 as number', function(err, recordset) {
 // ... error checks
 console.dir(recordset);
 });
 
 });

Document address:http://csdoc.org/
Why are the documents inconsistent? It’s really cheat people. It’s been a long afternoon!