Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model.count return type can be an Array #124

Open
bradleyboy opened this issue Sep 4, 2017 · 1 comment
Open

Model.count return type can be an Array #124

bradleyboy opened this issue Sep 4, 2017 · 1 comment

Comments

@bradleyboy
Copy link

Currently, Model.count has this signature:

count(options?: CountOptions): Promise<number>;

However, if you pass group options to the count call, the return is an array. For example, assuming a naive blog posts table with an author_id column:

const count = await Post.count(); 
// returns number

const count = await Post.count({group: ['author_id'], attributes: ['author_id']});
// returns [{count: 1, author_id: 1}, {count: 10, author_id: 2}];

The workaround is to add as any after the call to suppress warnings. Not sure what the proper fix is in the type definition itself, but happy to PR with guidance :)

@deepaknyk
Copy link

Has anyone found a fix for this yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants