{"action":"created","issue":{"url":"https://api.github.com/repos/kylefarris/node-querybuilder/issues/44","repository_url":"https://api.github.com/repos/kylefarris/node-querybuilder","labels_url":"https://api.github.com/repos/kylefarris/node-querybuilder/issues/44/labels{/name}","comments_url":"https://api.github.com/repos/kylefarris/node-querybuilder/issues/44/comments","events_url":"https://api.github.com/repos/kylefarris/node-querybuilder/issues/44/events","html_url":"https://github.com/kylefarris/node-querybuilder/issues/44","id":364474651,"node_id":"MDU6SXNzdWUzNjQ0NzQ2NTE=","number":44,"title":"Example in DELETE docs does not close connection on error","user":{"login":"Flamenco","id":819940,"node_id":"MDQ6VXNlcjgxOTk0MA==","avatar_url":"https://avatars2.githubusercontent.com/u/819940?v=4","gravatar_id":"","url":"https://api.github.com/users/Flamenco","html_url":"https://github.com/Flamenco","followers_url":"https://api.github.com/users/Flamenco/followers","following_url":"https://api.github.com/users/Flamenco/following{/other_user}","gists_url":"https://api.github.com/users/Flamenco/gists{/gist_id}","starred_url":"https://api.github.com/users/Flamenco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Flamenco/subscriptions","organizations_url":"https://api.github.com/users/Flamenco/orgs","repos_url":"https://api.github.com/users/Flamenco/repos","events_url":"https://api.github.com/users/Flamenco/events{/privacy}","received_events_url":"https://api.github.com/users/Flamenco/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-09-27T13:24:11Z","updated_at":"2018-09-27T15:20:17Z","closed_at":null,"author_association":"NONE","body":"See comment in snippet.\r\n\r\n```js\r\npool.get_connection(qb => {\r\n        qb.get('comments', {id: id}, (err, res) => {\r\n            // CONNECTION SHOULD BE CLOSED BEFORE RETURNING\r\n            if (err) return console.error(err);\r\n            const article_id = res.article_id;\r\n \r\n            qb.delete('comments', {id: id}, (err, res) => {\r\n                qb.release();\r\n                if (err) return console.error(err);\r\n \r\n                const page_data = {\r\n                    num_removed: res.affected_rows,\r\n                }\r\n                return res.render('/article/' + article_id, page_data);\r\n            });\r\n        });\r\n    });\r\n```\r\n\r\nOnce I need to make more than 1 DB call, this library starts to become very hard to manage due to lack of promise support.\r\n\r\nThe preceding issue would be avoided by using the following async/await syntax with promises returned from node-querybuilder.\r\n```js\r\nasync function render() {\r\n  let db\r\n  try {\r\n    db = await pool.get_connection()\r\n    let comments = await qb.get('comments', {id})\r\n    const article_id = comments.article_id;\r\n    const res = await qb.delete('comments', {id})\r\n    const page_data = {num_removed: res.affected_rows}\r\n    return res.render('/article/' + article_id, page_data)\r\n  } catch (err) {\r\n    console.error(err)\r\n  } finally {\r\n    if (db) db.release()\r\n  }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/kylefarris/node-querybuilder/issues/comments/425133629","html_url":"https://github.com/kylefarris/node-querybuilder/issues/44#issuecomment-425133629","issue_url":"https://api.github.com/repos/kylefarris/node-querybuilder/issues/44","id":425133629,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNTEzMzYyOQ==","user":{"login":"kylefarris","id":601654,"node_id":"MDQ6VXNlcjYwMTY1NA==","avatar_url":"https://avatars3.githubusercontent.com/u/601654?v=4","gravatar_id":"","url":"https://api.github.com/users/kylefarris","html_url":"https://github.com/kylefarris","followers_url":"https://api.github.com/users/kylefarris/followers","following_url":"https://api.github.com/users/kylefarris/following{/other_user}","gists_url":"https://api.github.com/users/kylefarris/gists{/gist_id}","starred_url":"https://api.github.com/users/kylefarris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kylefarris/subscriptions","organizations_url":"https://api.github.com/users/kylefarris/orgs","repos_url":"https://api.github.com/users/kylefarris/repos","events_url":"https://api.github.com/users/kylefarris/events{/privacy}","received_events_url":"https://api.github.com/users/kylefarris/received_events","type":"User","site_admin":false},"created_at":"2018-09-27T15:20:17Z","updated_at":"2018-09-27T15:20:17Z","author_association":"OWNER","body":"Haha, yeah, I would say that is pretty atypical indeed. Okay then, I'll go ahead and make v2 the master branch so you don't have to keep using `/next`."}}
{"actor":{"display_login":"kylefarris"}}