{"action":"created","issue":{"url":"https://api.github.com/repos/mysqljs/mysql/issues/1581","repository_url":"https://api.github.com/repos/mysqljs/mysql","labels_url":"https://api.github.com/repos/mysqljs/mysql/issues/1581/labels{/name}","comments_url":"https://api.github.com/repos/mysqljs/mysql/issues/1581/comments","events_url":"https://api.github.com/repos/mysqljs/mysql/issues/1581/events","html_url":"https://github.com/mysqljs/mysql/issues/1581","id":191450150,"number":1581,"title":"How to append new object property name  in a result row data packet query???","user":{"login":"dreweird","id":16024897,"avatar_url":"https://avatars.githubusercontent.com/u/16024897?v=3","gravatar_id":"","url":"https://api.github.com/users/dreweird","html_url":"https://github.com/dreweird","followers_url":"https://api.github.com/users/dreweird/followers","following_url":"https://api.github.com/users/dreweird/following{/other_user}","gists_url":"https://api.github.com/users/dreweird/gists{/gist_id}","starred_url":"https://api.github.com/users/dreweird/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dreweird/subscriptions","organizations_url":"https://api.github.com/users/dreweird/orgs","repos_url":"https://api.github.com/users/dreweird/repos","events_url":"https://api.github.com/users/dreweird/events{/privacy}","received_events_url":"https://api.github.com/users/dreweird/received_events","type":"User","site_admin":false},"labels":[{"id":93080581,"url":"https://api.github.com/repos/mysqljs/mysql/labels/question","name":"question","color":"d4c5f9","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-11-24T07:28:01Z","updated_at":"2016-11-29T04:47:51Z","closed_at":"2016-11-29T04:37:08Z","body":"```js\r\nvar data = {\r\n   \"data\"={}\r\n}\r\n connection.query(\"SELECT * FROM table\",function(err, rows, fields){\r\n       if(rows.length != 0){\r\n            rows['new'] = [1,2,3];\r\n             data[\"data\"]=rows\r\n           console.log(data);\r\n            res.json(data);\r\n      }\r\n})\r\n```\r\nIn console log the rows['new'] is not included...I want to append the new object to the result row and the output will be like this....\r\n```js\r\n{\r\n    \"data\": [\r\n        {\r\n            \"id\": 1,\r\n            \"name\": \"name\",\r\n            \"new\": [\r\n                1, 2, 3\r\n               ]\r\n        } and so on\r\n   ]\r\n}\r\n``\r\n\r\nSomebody help me with this??\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/mysqljs/mysql/issues/comments/263475254","html_url":"https://github.com/mysqljs/mysql/issues/1581#issuecomment-263475254","issue_url":"https://api.github.com/repos/mysqljs/mysql/issues/1581","id":263475254,"user":{"login":"sidorares","id":173025,"avatar_url":"https://avatars.githubusercontent.com/u/173025?v=3","gravatar_id":"","url":"https://api.github.com/users/sidorares","html_url":"https://github.com/sidorares","followers_url":"https://api.github.com/users/sidorares/followers","following_url":"https://api.github.com/users/sidorares/following{/other_user}","gists_url":"https://api.github.com/users/sidorares/gists{/gist_id}","starred_url":"https://api.github.com/users/sidorares/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sidorares/subscriptions","organizations_url":"https://api.github.com/users/sidorares/orgs","repos_url":"https://api.github.com/users/sidorares/repos","events_url":"https://api.github.com/users/sidorares/events{/privacy}","received_events_url":"https://api.github.com/users/sidorares/received_events","type":"User","site_admin":false},"created_at":"2016-11-29T04:47:51Z","updated_at":"2016-11-29T04:47:51Z","body":"@dreweird ideally you should avoid mutating values returned by 3rd party library, in JS it's very easy to make a copy:\r\n\r\n```js\r\n   connection.query(\"SELECT * FROM table\", (err, rows) => {\r\n      data.data = rows.map((r) => Object.assign({}, r, {\"new\": [1, 2, 3]}))\r\n      res.json(data)\r\n   })\r\n```\r\n"}}
{"actor":{"display_login":"sidorares"}}