mirror of
https://gitlab.com/Alamantus/Readlebee.git
synced 2025-05-15 06:31:17 +02:00
- Split models & associations into their own files - Update columns and requirements - Create PermissionLevel model & add to relevant models
17 lines
No EOL
470 B
JavaScript
17 lines
No EOL
470 B
JavaScript
const path = require('path');
|
|
const fs = require('fs');
|
|
|
|
module.exports = models => {
|
|
const associatedModels = {};
|
|
|
|
Object.keys(models).forEach(modelName => {
|
|
const associationFileName = path.resolve(__dirname, modelName, '.js');
|
|
if (fs.existsSync(associationFileName)) {
|
|
associatedModels[modelName] = require(associationFileName)(models);
|
|
} else {
|
|
associatedModels[modelName] = models[modelName];
|
|
}
|
|
});
|
|
|
|
return associatedModels;
|
|
}; |