Skip to content

How to adjust the query result format? #995

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

Closed
zacard-orc opened this issue Feb 15, 2015 · 2 comments
Closed

How to adjust the query result format? #995

zacard-orc opened this issue Feb 15, 2015 · 2 comments
Labels

Comments

@zacard-orc
Copy link

Normally,the query result is the format below :

[
    {
        "ddtime": "20150215 12:21:56",
        "url": "ct.ctrip.com",
        "succ": 9,
        "fail": 0,
        "succ_r": 100
    },
    {
        "ddtime": "20150215 12:21:56",
        "url": "download.hhtravel.com",
        "succ": 288,
        "fail": 9,
        "succ_r": 96.97
    },

Could you tell me ,how to set the config parameters to adjust the format to this style by 'node-mysql' module

{
  "data": [
    [
      "Tiger Nixon",
      "System Architect",
      "Edinburgh",
      "5421",
      "2011/04/25",
      "$320,800"
    ],
    [
      "Garrett Winters",
      "Accountant",
      "Tokyo",
      "8422",
      "2011/07/25",
      "$170,750"
    ],

so i can reduce the jquery convert job on the front end.
Tks

@sidorares
Copy link
Member

no, right now you have to convert rows (as array of objects where key is field name) into array manually
see #770 #981 #658

@dougwilson
Copy link
Member

Yes, there are no configuration options you can pass to this library to make it output in that format. @sidorares referenced some open issues that if they were fixed, would bring you much closer. Feel free to contribute an implementation as a PR! Barring that, you'll just have to process it on your server to transform it to the desired format, probably using Underscore.js or lodash.

dveeden pushed a commit to dveeden/mysql that referenced this issue Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants