-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Make more efficient query #1958
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
Conversation
Note that I blind coded this, so definitely check out in the preview if it works. reference: https://www.algolia.com/doc/api-reference/api-methods/get-objects/?language=javascript I also changed the require out for the way smaller `algoliasearch/lite`
| index.search({ query: dependency, hitsPerPage: 1 }, (err, { hits }) => { | ||
| const versions = Object.keys(hits[0].versions).sort((a, b) => { | ||
| index.getObject(dependency, ['versions']).then(({ versions: hits }) => { | ||
| const versions = Object.keys(hits).sort((a, b) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd keep calling this versions though, since hits is a list of packages usually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh I see the problem now, the variable was declared twice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The names clash, that's why I renamed it.
Im gonna rename to results, is that a better name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
index.getObject(dependency, ['versions']).then(result =>
const versions = Object.keys(result.versions).sort((a, b) => {
This could work too
Finishing of #1954
cc @Haroenv