-
Notifications
You must be signed in to change notification settings - Fork 8
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
please add an option to get fields information #13
Comments
A third option would be to add the i.e. the then-mysql code would look something like: const results = [...results];
results.fields = fields;
return fields; I would accept any of the three proposals, please select whichever you feel provides the best developer experience, keeping in mind that the most important use case is people who just want the results of the query, and do not need the added metadata. |
Neat, I did not think of that one. I am pretty new to the Node.js ecosystem, if I change anything do I have to update any meta-files or will the sourcecode be enough? Also, after incorporating the change in then-mysql, do I have to refer to the new version of it somewhere when doing the changes in sync-mysql? |
If you make the change to then-mysql, it will automatically be picked up by this package. The only file you should need to edit is https://github.com/then/then-mysql/blob/master/lib/connection.js |
When adding the fields property to the rows-array as you proposed, it somehow is treated as an element of the array and gets assigned an index, as if I had added it with My change in https://github.com/then/then-mysql/blob/master/lib/connection.js was to add the line I cannot reproduce this behaviour for properties of arrays anywhere else, not in browsers and not in Node.js other than this instance. Do you have any idea what could cause this? Edit: Of course I also added the fields parameter to the anonymous function used as a callback on line 45. |
Can you submit a pull request with your proposed changes. It's really hard to interpret what change you've made from this. |
I want to access the fields property after I have made a query. In the normal async mysql package this would be the third argument passed into the callback of the query-function.
The current implementation always only returns the result-rows. To enable it to return both, the result-rows and the fields, the then-mysql package (also authored by you) would have to be changed as well. In connection.js only a small change would have to be made to the lines 45-47, so when the Promise is resolved it also returns the fields. However, in order not to break existing code, either a second version of the query-method would have to be added which is nearly a clone of the existing one, or you could add a parameter that defaults to the current behaviour, but can be configured so the promise returns e.g. an object like { result, fields }.
With that change in then-mysql, it would be easy to adapt sync-mysql to work with it.
I could write that myself and provide a PR, but I'm not sure in what style you would like the change to be implemented.
The text was updated successfully, but these errors were encountered: