I've seen this syntax to access a defined model from the Sequelize instance:
var sequelize = new Sequelize('database', 'username'[, 'password']);
var Project = sequelize.define('Project', {
title: Sequelize.STRING,
description: Sequelize.TEXT
});
sequelize.Project.build({});
However, when I tried it myself on 1.7.0:
console.log(sequelize.Project);
Returned undefined
Is there another way or a correct way to accomplish this?
You need to attach the object on your own. Usually people do something like:
sequelize.Project = sequelize.import('./models/project');
Sequelize doesn't do that for you. (The fact that people decide to attach models to the sequelize object is purely a convenience thing that emerged)
Source: Github Issues #1693
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With