Quando tento testar minha rota pessoa estou recebendo o erro "Cannot read property 'findAll' of undefined" Alguem consegue me ajudar ?
people.js
'use strict';
const {
Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
class People extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
static associate(models) {
// define association here
}
};
People.init({
status: DataTypes.BOOLEAN,
name: DataTypes.STRING,
email: DataTypes.STRING,
role: DataTypes.STRING
}, {
sequelize,
modelName: 'people',
});
return People;
};
PeopleController.js
const database = require('../models');
class PeopleController {
static async ReadAll (req, res) {
try {
const allPeople = await database.People.findAll();
return res.status(200).json(allPeople);
}
catch (error) {
return res.status(500).json(error.message);
};
}
};
module.exports = PeopleController;