Skip to content

Typings for the Model.count() method are inaccurate #13871

@PythonCoderAS

Description

@PythonCoderAS

Issue Creation Checklist

[x] I have read the contribution guidelines

Bug Description

The TypeScript typings indicate that whenever the group option is provided to the Model.count() function, then an object will be returned with variable string keys containing numbers. However, what is actually returned is an array of objects, which contain the values for the given attributes supplied to the group option and a count key containing the actual number of results.

SSCCE

Here is the link to the SSCCE for this issue: sequelize/sequelize-sscce#208

What do you expect to happen?

See above.

What is actually happening?

See above. Another view of output:

> await AutoUser.count({ ... group: ["hour", "minute"] ... }) [ { hour: 5, minute: 40, count: 1 } ] > await AutoUser.count({ ... group: ["hour"] ... }); [ { hour: 5, count: 1 } ]

Additional context

N/A

Environment

  • Sequelize version: sequelize@6.12.4
  • Node.js version: v17.3.0
  • If TypeScript related: TypeScript version: typescript@4.5.4

Bug Report Checklist

How does this problem relate to dialects?

  • I think this problem happens regardless of the dialect.
  • I think this problem happens only for the following dialect(s):
  • I don't know, I was using PUT-YOUR-DIALECT-HERE, with connector library version XXX and database version XXX

Would you be willing to resolve this issue by submitting a Pull Request?

  • Yes, I have the time and I know how to start.
  • Yes, I have the time but I don't know how to start, I would need guidance.
  • No, I don't have the time, although I believe I could do it if I had the time...
  • No, I don't have the time and I wouldn't even know how to start.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions