TypeError: Class constructor User cannot be invoked without 'new'
Issue
TypeError: Class constructor User cannot be invoked without 'new'
Versions
"routing-controllers": "^0.9.0",
"sequelize": "^6.5.0",
"sequelize-typescript": "^2.1.0",
"tsc": "^1.20150623.0",
"tslint": "^6.1.3"
Issue type
- [X] bug report
- [ ] feature request
Actual behavior
TypeError: Class constructor User cannot be invoked without 'new'
Expected behavior
It should return the rows with the included rows
Steps to reproduce
Query with an include
Related code
The issue when I use include. Im using routiing-controllers Snippet from the route handler that caused this particular error
const posts = await Post.findAll({
where: {community_id: community},
include: [User],
order: [['created_at', 'DESC']]
})
return posts;
Any ideas on how to fix? I'm following the documentation directly.
@ColtraneNadler Have you ever managed to find a solution to this?
I'm also looking for a solution here. I'm using es target es2017
fwiw, this post solved it for me https://stackoverflow.com/a/68602295
use this
const posts = await Post.findAll({ where: {community_id: community}, include: [User], order: [['created_at', 'DESC']] })
return posts.get({ plain: true });