Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support replace namespaces with multiple schemas using the same models #5

Open
jdnichollsc opened this issue Nov 4, 2016 · 3 comments

Comments

@jdnichollsc
Copy link
Contributor

Hi my friend,

I have other idea, what do you think about the following option?

/path/to/models
├── user.js
├── schemaOne
│   ├── product.js
│   └── contact.js
├── schemaTwo
│   ├── email.js
│   └── template.js
└── index.js

And in the index.js

var models = require('sequelize-auto-import')(sequelize, '/path/to/models', {
   schemas: {
      schemaOne: ['company1', 'company2'],
      schemaTwo: ['company3', 'company4']
   }
});

And access the models in this way:

models.user
models.company1.product
models.company1.contact
models.company2.product
models.company2.contact
models.company3.email
models.company3.template
models.company4.email
models.company4.template

Maybe is more powerful option! haha

Regards, Nicholls

@bjrmatos
Copy link
Owner

bjrmatos commented Nov 4, 2016

hahaha, well i'm ok with this. but this way to specify the schemas option (object) should deprecate the old one (array), because it is more powerful and let you customize the folder name(s)

@jdnichollsc
Copy link
Contributor Author

Yes! Or maybe we can detect if the schemas option is an array or an object to apply the correct option.

@bjrmatos
Copy link
Owner

bjrmatos commented Nov 4, 2016

i would prefer just the new type (object) 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants