Closed charlielidbury closed 6 years ago
There's a branch that I'm working on that brings this back.
On Thu, 5 Jul 2018, 12:23 Charlie, notifications@github.com wrote:
In vanilla node-mysql you can get the fields of a returned query like this:
con.query("...", (err, results, fields) => { console.log(fields) } )
But with node-promise-mysql it seems to have lost that ability:
con.query("...") .then((results, fields) => { console.log(fields) // undefined });
This feels like something that has been overlooked, I was hesitant to post this as an issue as I might just be looking in the wrong place; but I can't figure out how to get the columns.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lukeb-uk/node-promise-mysql/issues/94, or mute the thread https://github.com/notifications/unsubscribe-auth/AEjy1Fhq_dXdcr2EE5X7AvYq6Pp5dz4wks5uDfcygaJpZM4VDtTh .
Is there any way I could access that branch? If it's stable that is. I don't need the majority of the package's functionality.
NB: Jesus that was a quick reply
You can get it here: https://github.com/lukeb-uk/node-promise-mysql/tree/mysql-wrapper
If you pass returnArgumentsArray: true
into your connection config object then you'll get an array back as the argument to the promise, so you can do:
con.query("...")
.then(([results, fields]) => {
console.log(fields);
});
Thanks man! Is there any way I could unpack the array before passing it as arguments so I could still use it in the clean results => { ... }
way instead of having to do ([results, fields]) => { ... }
every time?
Unfortunately not, promises only take one argument.
Ah that's a shame. Seems like a pretty pointless restriction.
It's what's in the spec 🤷♂️
If this issue is resolved, please close it
Ah sorry about that, forgot closing issues was a thing. :P
In vanilla node-mysql you can get the fields of a returned query like this:
But with node-promise-mysql it seems to have lost that ability:
This feels like something that has been overlooked, I was hesitant to post this as an issue as I might just be looking in the wrong place; but I can't figure out how to get the columns.
Thank you in advance!