Sequelize findAll is not a function
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() ...
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