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

feat: add getResultAndCount #3885

Closed
rubiin opened this issue Dec 30, 2022 · 2 comments · Fixed by #3891
Closed

feat: add getResultAndCount #3885

rubiin opened this issue Dec 30, 2022 · 2 comments · Fixed by #3891
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@rubiin
Copy link
Contributor

rubiin commented Dec 30, 2022

Is your feature request related to a problem? Please describe.
On typeorm we can use a function called getManyAndCount which can be used on querybuilder
that executes SQL query and returns entities and overall entities count (without limitation)

Describe the solution you'd like
Add a function getResultAndCount which returns the count and the entities as well
Example:

const [result, total] = await qb
			.take(limit)
			.skip(offset)
			.getManyAndCount();

Describe alternatives you've considered
For now we can do,

const result = await qb.getResult()
const total = await qb.clone().count("id", true).execute("get")

Additional context
The typeorm implementation can be found here
https://github.com/typeorm/typeorm/blob/15a4eb942e2d794eb5975e7a9e8b16cfe478a026/src/query-builder/SelectQueryBuilder.ts#L1832

@rubiin rubiin added the enhancement New feature or request label Dec 30, 2022
@B4nan B4nan added the good first issue Good for newcomers label Dec 30, 2022
@erie0210
Copy link
Contributor

Can I try this one ? 🙌

@B4nan
Copy link
Member

B4nan commented Dec 31, 2022

Sure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants