我正在尝试将 mysql 数据库连接到我的 sailsjs 应用程序
在config/connections.js
localMysql:{ //arbitrary name
adapter: 'sails-mysql',
host: '127.0.0.1',
port: 3306,
user: 'root',
password: 'root'
}
和config/models.js
module.exports.models = {
connection:localMysql
}
But i got the following error
include-all
attempted torequire(/var/www/node/sails-test/config/models.js)
, but an error occurred:: Details:ReferenceError: localMysql is not defined
最佳答案
您需要传递一个字符串
:
module.exports.models = {
connection: 'localMysql'
};
http://sailsjs.com/documentation/reference/configuration/sails-config-connections
关于javascript - sails.js:mysql 连接失败 ReferenceError: localMysql 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44469593/