Monday 13 January 2020

Using Connection URIs with Read Replication in Sequelize

If I have a connection URI, I can use that normally with Sequelize as such:

const sequelize = new Sequelize('postgres://user:pass@example.com:5432/dbname');

However, if I want to use Read and Write replication (https://sequelize.org/master/manual/read-replication.html), then there doesn't seem an option to use connection URI. Can I pass connection URI strings to read and write in the replication option as in:

const sequelize = new Sequelize(null, null, null, {
  dialect: 'postgres',
  replication: {
    read: [
      'postgres://user:pass@reader.example.com:5432/dbname',
      'postgres://user:pass@anotherreader.example.com:5432/dbname'
    ],
    write: 'postgres://user:pass@writer.example.com:5432/dbname'
  }
})


from Using Connection URIs with Read Replication in Sequelize

No comments:

Post a Comment