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

const model = require(path.join(__dirname, file)).default( ^ TypeError: require(...).default is not a function #1382

Open
DasoTD opened this issue Sep 14, 2023 · 1 comment

Comments

@DasoTD
Copy link

DasoTD commented Sep 14, 2023

fs.readdirSync(__dirname)
.filter((file) => {
return (
file.indexOf(".") !== 0 && file !== basename && file.slice(-3) === ".js"
);
})
.forEach((file) => {
const model = require(path.join(__dirname, file)).default(
sequelize,
Sequelize.DataTypes
);
db[model.name] = model;
});

Object.keys(db).forEach((modelName) => {
if (db[modelName].associate) {
db[modelName].associate(db);
}
});

db.sequelize = sequelize;
db.Sequelize = Sequelize;

module.exports = db;

@mohak34
Copy link

mohak34 commented Sep 30, 2023

@DasoTD Can you provide me with the file name so i can work on this issue

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

No branches or pull requests

2 participants