sequelize-typescript
sequelize-typescript copied to clipboard
Type Error using sub querys, sum, count, etc.
Versions
- sequelize: ^6.5.0
- sequelize-typescript: ^2.0.0
- typescript ^3.6.3
I'm submitting a ...
[ X ] bug report [ ] feature request
Actual behavior:
When I do some subquery or sum, count, etc. The typescript informs an error because the return is not in Model.
-->
const [{ totalDuration }] = await TaskModel.findAll({
attributes: [
[Sequelize.fn('sum', Sequelize.col('duration')), 'totalDuration'],
],
group: ['task_list_id'],
where: {
task_list_id: id,
status: { [Op.or]: ['in_progress', 'not_started'] },
},
});
Having the same issue.
Workaround is to add declare totalDuration: number | undefined to your Model, but it's not an ideal solution.
Getting same error