将mysql2连接导出到其他文件节点js

问题描述

我正在尝试对节点和 MysqL2 项目中的所有文件使用一个连接。

这就是我所做的->

// db.js

const MysqL = require('MysqL2')

const connection = MysqL.createConnection({dbinfo})

console.log(connection) // the connection is proper

module.exports = { connection }
//server.js

const { con } = require('./db')

console.log(con) //returns undefined

如果我将 MysqL 包与 MysqL2 一起使用,类似的事情也会起作用

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)