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

MySQL : Count result accessible only via ‘$extras’ field #28

Open
ad-momo opened this issue Sep 24, 2024 · 0 comments
Open

MySQL : Count result accessible only via ‘$extras’ field #28

ad-momo opened this issue Sep 24, 2024 · 0 comments

Comments

@ad-momo
Copy link

ad-momo commented Sep 24, 2024

Package version

@adonisjs/lucid 21.1.0

Describe the bug

Hello 👋,

For a count('*', alias) query, the result cannot be retrieved directly with the alias. You have to use the $extras field.

Database engine : MySQL 8.0.39 (Homebrew)
OS : macos14.4 (arm64)
MySQL Client NodeJS : mysql2 3.10.3

const users = await db
  .from('users')
  .count('*', 'total')

console.log(users[0].total) // undefined
console.log(users[0].$extras.total) // work correctly 

Thanks 😀

Reproduction repo

No response

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

1 participant