如何使用Sequelize指定只读副本?
我根据他们的文档创建了一个非常基本的测试。
https://github.com/sequelize/sequelize/blob/master/docs/usage.md
var Sequelize = require("sequelize");
var sequelize = new Sequelize('database', 'root', '', {
dialect: 'mysql',
port: 3306,
replication: {
read: [
{ host: 'host1' }
],
write: { host: 'host2' }
},
pool: { // If you want to override the options used for the read pool you can do so here
maxConnections: 20,
maxIdleTime: 30000
}
})
var Test = sequelize.define('grammar_scores', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true
},
user_id: {
type: Sequelize.INTEGER,
index: true
}
}, {
underscored: true
});
Test.findAll({ where:{user_id:89} }).success(console.log);
会抛出以下错误......
/Users/tim/code/sequelizetest/node_modules/sequelize/lib/dialects/mysql/connector-manager.js:333
if (config.pool !== null && config.pool.handleDisconnects) {
^
TypeError: Cannot read property 'handleDisconnects' of undefined
at module.exports.connect (/Users/tim/code/sequelizetest/node_modules/sequelize/lib/dialects/mysql/connector-manager.js:333:44)