Hi everyone!
Basicaly im trying make a association between two tables but i never used sequelize to do that, so it's my first time trying but when i do that here
...
import TaskModel from "./task.model";
interface UserCreationAttributes extends Optional<UserInterface, 'userId' | 'tasksConcluded'> {}
class UserModel extends Model<UserInterface, UserCreationAttributes> implements UserInterface {
...
}
UserModel.init(
...
);
UserModel.hasMany(TaskModel, { foreignKey: 'ownerId' }); // <-- here
export default UserModel;
and here
...
import UserModel from "./user.model";
interface TaskCreationAttributes extends Optional<TaskInterface, 'taskId' | 'status'> {}
class TaskModel extends Model<TaskInterface, TaskCreationAttributes> implements TaskInterface {
...
}
TaskModel.init(
...
);
TaskModel.belongsTo(UserModel, { foreignKey: 'ownerId' }); <-- here too
export default TaskModel;
i got this error message
2024-12-24T13:49:06.011-03:00 - error: uncaughtException: TaskModel.belongsTo called with something that's not a subclass of Sequelize.Model
Error: TaskModel.belongsTo called with something that's not a subclass of Sequelize.Model