Dio
04/04/2024, 8:20 AMspand
04/04/2024, 8:36 AMDatabase
to the transaction functionDio
04/04/2024, 8:40 AMconst sequelize = new Sequelize('database', null, null, {
dialect: 'mysql',
port: 3306,
replication: {
read: [
{ host: '8.8.8.8', username: 'read-1-username', password: process.env.READ_DB_1_PW },
{ host: '9.9.9.9', username: 'read-2-username', password: process.env.READ_DB_2_PW }
],
write: { host: '1.1.1.1', username: 'write-username', password: process.env.WRITE_DB_PW }
},
pool: { // If you want to override the options used for the read/write pool you can do so here
max: 20,
idle: 30000
},
})
spand
04/04/2024, 8:45 AMtransaction(masterDb) {
// DO stuff
}
transaction(readDb) {
// Do stuff
}
You can even get the read pool by:
transaction(masterDb) {
// DO stuff
}
transaction(readDbList.random()) {
// Do stuff
}
spand
04/04/2024, 8:47 AMDio
04/04/2024, 8:54 AMspand
04/04/2024, 8:55 AMArjan van Wieringen
04/06/2024, 1:36 PMArjan van Wieringen
04/06/2024, 1:39 PMspand
04/07/2024, 7:04 AMArjan van Wieringen
04/07/2024, 9:58 AMDio
04/08/2024, 2:57 AM