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

Return array of arrays rather than objects #1784

Closed
DedDorito opened this issue Jul 25, 2017 · 3 comments
Closed

Return array of arrays rather than objects #1784

DedDorito opened this issue Jul 25, 2017 · 3 comments

Comments

@DedDorito
Copy link

DedDorito commented Jul 25, 2017

This is half feature request / half question.

First, is it possible to return an array of arrays rather than an array of objects? It doesn't appear this functionality is officially supported. Is there a slight hack that I could implement myself to achieve this?

Second, how are the column names added? Does the query actually return the column names for every single row, or does the query simply return the headers once and this library duplicates them while constructing the object for each row?

Thanks!

EDIT: To clarify about the "slight hack" comment, I realize I can do something like rows.map(row => row.column) but I was trying to avoid the slight overhead of constructing the array of objects in the first place only to map it back to an array.

@sidorares
Copy link
Member

Duplicate of #1637

@sidorares sidorares marked this as a duplicate of #1637 Jul 25, 2017
@sidorares
Copy link
Member

Second, how are the column names added? Does the query actually return the column names for every single row, or does the query simply return the headers once and this library duplicates them while constructing the object for each row?

No, it returns fields packets first, and then rows: http://web.archive.org/web/20160604100755/http://dev.mysql.com/doc/internals/en/com-query-response.html#packet-COM_QUERY_Response

graphviz-3ab2ba81081a7f3cc556d11fd09f50341bba6f15

@DedDorito
Copy link
Author

Awesome, thanks for explaining that.

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

No branches or pull requests

2 participants