Return objects rather than arrays
See original GitHub issueThe node.js project node-postgres or pg returns objects rather than rows of arrays. It was elegant to work with. Is there a reason this project only returns an array of arrays? Am I missing something?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:5 (2 by maintainers)
Top Results From Across the Web
php - Why return object instead of array? - Stack Overflow
An array is just an index of values. Whereas an object contains methods which can generate the result for you.
Read more >Objects vs. Arrays - Medium
Both objects and arrays are considered “special” in JavaScript. Objects represent a special data type that is mutable and can be used to...
Read more >Data Structures: Objects and Arrays - Eloquent JavaScript
Many types of information require more than one atom, though. ... You give it an object, and it returns an array of strings—the...
Read more >BrandonSavage.net Stop returning arrays (use objects instead)
The reason is simple: when one object makes a request to another object, it should generally get back an object unless the response...
Read more >Practical JavaScript: Arrays vs. Objects - Towards Data Science
Think about what your particular data represents: If it's a single entity with named properties, you want an object. If it's a group...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

IMO we should copy what node-postgres does.
What about something like:
(Could be improved but you get the gist)
I’ve actually implemented something similar in a Deno project that uses deno-postgres but that was obviously manual work, and each db query calls that method to get the data in key value pairs