I can't import the generated models, this is my code 👍
const db = {}
const __dirname = "models"
fs
.readdirSync(__dirname)
.forEach((file) => {
var a = path.join(__dirname, file);
const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes)
db[model.name] = model;
})
db.sequelize = sequelize;
db.Sequelize = Sequelize;
module.exports = db;
The error 👍
Unable to connect to the database: { Error: Cannot find module 'models\customers.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at fs.readdirSync.forEach (C:\uwamp\www\vue-node-mysql-generated\server.js:138:35)
at Array.forEach (<anonymous>)
at sequelize.authenticate.then (C:\uwamp\www\vue-node-mysql-generated\server.js:136:18)
at process._tickCallback (internal/process/next_tick.js:68:7) code: 'MODULE_NOT_FOUND' }
Hello,
I can't import the generated models, this is my code 👍
The error 👍
Can somebody give me the right code ?
This is the generated customers.js
This other command is not working as well ;
import CustomersModel from '/models/customers.js'
SyntaxError: Unexpected identifier
This oher code doesnt work