Skip to content

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

@jdnichollsc

Description

@jdnichollsc

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions