问题描述
我一直在使用只读副本进行续集设置。我总是在查询中使用原始查询。但是我所有的问题都被直接问到了我的主人。
续集设置:
dialect: 'MysqL',port: envConfig.appDbConfig.port,dialectOptions: {
typeCast: function (field,next) { // for reading from database
if (field.type === 'DATETIME') {
return field.string()
}
return next()
}
},timezone: '+08:00',logging: false,replication: {
read: [{
host: xxxx,username: xxxx,password: xxxx
}],write: {
host: yyyy,username: yyyy,// password: yyyy
password: yyyy
}
},pool: { // If you want to override the options used for the read pool you can do so here
maxConnections: 20,maxIdleTime: 30000
},raw: true
})
写查询:
await sequelizeConn.query(`insert into transactions_audit(col1,col2)values('value1','value2')')
读取查询:
const transactionfromDB = await sequelizeConn.query(`select * from transactions_audit where umber = 'xxx' and id = '1'`,{ raw: true })
请帮助我在这里缺少什么。我想让我的读取查询转到我的只读副本。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)