nodejs pg split read/write request to database

Viewed 128

My work is based on nodejs and using

const { Pool } = require('pg');
const pool = new Pool({
  user: process.env.USER,
  host: process.env.HOST,
  port: 5432,
  database: "database1",
  password: password,
});
const knex = require('knex')({ client: 'pg' });

knex
    .select('u.user_id')
    .from({ u: 'User' })

There are 2 databases in each aws RDS

  • master
  • replica-master

I want knex.select uses replica-master database and write user master. How could I configure this?

0 Answers
Related