balderdashy / sails

Realtime MVC Framework for Node.js
https://sailsjs.com
MIT License
22.84k stars 1.95k forks source link

read and write from different database #7051

Open shobhitsinghal624 opened 4 years ago

shobhitsinghal624 commented 4 years ago

Node version: v10.18.0 Sails version (sails): v1.1.0 ORM hook version (sails-hook-orm): Sockets hook version (sails-hook-sockets): Organics hook version (sails-hook-organics): Grunt hook version (sails-hook-grunt): Uploads hook version (sails-hook-uploads): DB adapter & version (e.g. sails-mysql@5.55.5): sails-postgresql@1.0.2 Skipper adapter & version (e.g. skipper-s3@5.55.5):


We have a read-replica of our main database (PostgreSQL on AWS RDS), and want the find() queries for some models to point to that read-replica instead of the main database. How should we go about doing this?

sailsbot commented 4 years ago

@shobhitsinghal624 Thanks for posting! We'll take a look as soon as possible.

In the mean time, there are a few ways you can help speed things along:

Please remember: never post in a public forum if you believe you've found a genuine security vulnerability. Instead, disclose it responsibly.

For help with questions about Sails, click here.

eashaw commented 4 years ago

Hi @shobhitsinghal624, It's probably worth thinking about if this you need a read-replica database or if it could wait. I know Postman eventually ran into a need for read-replicas at scale and made some modifications to do this with Sails and MySQL. It isn't ideal, but a workaround you could try is creating read only copies of your models that are stored on the read-replica and query those.