But i am getting this error: Error: Post.belongsTo called with something that's not a subclass of Sequelize.Model
I tried following:
Post.belongsTo(sequelize.model("User")) - This is throwing Error: User has not been defined.
Post.belongsTo("User") - This is throwing Error: Post.belongsTo called with something that's not a subclass of Sequelize.Model
I also tried using Post.associate but that method is not available in the version of sequelize i am using (6.37.3).
I want to populate all posts related to the user based on user.id.
I have a model called users.model.js
And another model called posts.model.js
I am trying to populate all the posts that belongs to a user using below code:
But i am getting this error: Error: Post.belongsTo called with something that's not a subclass of Sequelize.Model
I tried following:
Post.belongsTo(sequelize.model("User")) - This is throwing Error: User has not been defined. Post.belongsTo("User") - This is throwing Error: Post.belongsTo called with something that's not a subclass of Sequelize.Model I also tried using Post.associate but that method is not available in the version of sequelize i am using (6.37.3). I want to populate all posts related to the user based on user.id.