IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    mysql release有没有更好的写法?

    WangDongYao发表于 2017-03-23 13:44:27
    love 0

    如果先调用connection.release(),就不会走return的代码,尝试使用try/catch/finally可以实现,但是感觉不好看,connection.release()是否有更优雅的使用方法,看文档定义是这样的,When you are done with a connection, just call connection.release() and the connection will return to the pool, ready to be used again by someone else.大家平时怎么处理release的?

    		let connection = await mysqlPool.getConnection();
            let comment_count = await connection.query(sql, tid);
            console.log('mysql exec.');
            let count = comment_count[0]['count'];
            
            connection.release();
            return count;
    


沪ICP备19023445号-2号
友情链接