KSDaemon/sails-hook-sequelize

Allow sharing of model definitions among datasources

Opened this issue · 1 comments

Is your feature request related to a problem? Please describe.
My organization is creating a multitenant application using Sails, with Sequelize as our ORM to connect to existing database(s). Our goal is for new tenants with separate datasources to be able to be added purely through configuration changes. However, currently each model can be associated with only a single Sequelize instance.

Describe the solution you'd like
A way to namespace Models so that model multiple instances which function identically but point to different datasources can be created.

Describe alternatives you've considered
We could create separate model definitions for each tenant and explicitly name which datasource to associate with, but this violates our configuration-only requirement and will caused an ever-increasing maintenance burden as the number of models, tenants and places where they are used grow. (x models times y tenants times z places where a model is used and which one to use must be determined)

Hi @Damienmarble! Hmm... Interesting feature. I personally don't see use cases for this.
But if someone decides to implement it without breaking major API — I'll gladly merge his PR :)
I see that @ThisIsNoZaku is working on this.