We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
It would be great if we could get results count using the query builder, currently it seems not to be possible
For example:
const qb = ctx.em.createQueryBuilder(...).where(...); let result = qb.getResult(); let total = qb.getCount(); await Promise.all([results, total]);
The text was updated successfully, but these errors were encountered:
Just use qb.execute()
Sorry, something went wrong.
Yes, currently im doing this:
const total = (await qb.select("count(*) as total").execute("get")).total; const result = await qb.select(...).limit(limit).offset(offset).execute();
but it would be nice and cleaner if we could just use getCount like TypeORM
https://github.com/typeorm/typeorm/blob/7a0f7733f2cf704d60548a6b15d1fa2977a9e401/src/query-builder/SelectQueryBuilder.ts#L1141
I said you should use execute to read the results, there is already qb.count() method. Correct way is:
execute
qb.count()
const res = await qb.count().where(...).execute(); // `res.count` is the count
But sure, we can have getCount() too in v5. Care to send a PR?
getCount()
f773736
No branches or pull requests
It would be great if we could get results count using the query builder, currently it seems not to be possible
For example:
The text was updated successfully, but these errors were encountered: