KSDaemon / sails-hook-sequelize

Sails.js hook to use sequelize ORM
MIT License
67 stars 53 forks source link

Allow sharing of model definitions among datasources #60

Open Damienmarble opened 5 years ago

Damienmarble commented 5 years ago

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)

KSDaemon commented 5 years ago

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.