Skip to content

Commit

Permalink
fix: use sequelize.exclude instead of sequelize.ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
dead-horse committed Aug 20, 2018
1 parent a08029f commit 63a2567
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ exports.sequelize = {
password: '',
// delegate: 'myModel', // load all models to `app[delegate]` and `ctx[delegate]`, default to `model`
// baseDir: 'my_model', // load all files in `app/${baseDir}` as models, default to `model`
// ignore: 'index.js', // ignore `app/${baseDir}/index.js` when load models, support glob and array
// exclude: 'index.js', // ignore `app/${baseDir}/index.js` when load models, support glob and array
// more sequelize options
};
```
Expand Down
8 changes: 7 additions & 1 deletion lib/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,15 @@ module.exports = app => {

const models = [];
const target = Symbol(config.delegate);

if (typeof config.ignore === 'string' || Array.isArray(config.ignore)) {
app.deprecate(`[egg-srequelize] if you want to exclude ${config.ignore} when load models, please set to config.sequelize.exclude instead of config.sequelize.ignore`);
config.exclude = config.ignore;
delete config.ignore;
}
app.loader.loadToApp(modelDir, target, {
caseStyle: 'upper',
ignore: config.ignore,
ignore: config.exclude,
filter(model) {
if (!model || !model.sequelize) return false;
models.push(model);
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/apps/datasources/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exports.sequelize = {
baseDir: 'sequelize',
database: 'test1',
dialect: 'mysql',
ignore: 'Person.js',
exclude: 'Person.js',
},
],
};
Expand Down

0 comments on commit 63a2567

Please sign in to comment.