I\'m making a project with Sequelize and I\'m stucked in this step. The problem is that when I try to log in and the passport-local code is executed, when it reaches the
The nuke_users
module is exporting a function that, when called, returns the Model
. Because you aren't calling this function, it is not returning the Model
, and thus the function you are looking for does not exist.
To call this exported function you would need to pass in the sequelize
instance and DataTypes
, as so:
var User = require('../models/nuke_users')(sequelize, DataTypes);
In your case you are using a loader in the index.js
file, and it is exporting the db
object which contains the models keyed by their name.
var models = require('../models'); // loads index.js
var User = models.nuke_user; // the model keyed by its name
User.findOne(...); // search the model
Instead of returning the model, export it from NukeUser.js
:
const NukeUser = sequelize.define('nuke_users', {
// ...
});
module.exports = NukeUser;
Then in index.js
:
const NukeUser = require('../models/NukeUser');
NukeUser.findAll() //.then() ...