-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Make Result iterable #2861
base: master
Are you sure you want to change the base?
Make Result iterable #2861
Conversation
Make `Result` automatically iterable, so one can iterate through data without having to access `rows` explicitly: ```js client.query('select...', (err, res) => { // below we can use just "res", not "res.rows" for(const a of res) { console.log(a); // print the row } }) ```
In an afterthought, it would make the library perform better, if This PR above is a first step toward that. For now, it just forwards into The bottom line, modern development practices gravitate toward iterables versus pre-built lists. |
This is to align with [this main-driver change](brianc/node-postgres#2861). The two PR-s should be merged at the same time.
I don’t think this is worth changing now.
It’s nice when there’s just one way to do it. |
This caters for all coding styles, without any change in functionality. It also opens a path to changing types conversion, to become dynamic. There are lots of libraries these days that handle iterables well. |
Make
Result
automatically iterable, so one can iterate through rows without having to accessrows
explicitly:This also simplifies data processing when you want to process it as just iterable, all the way, not as an array.