Title: How to use path params and body in a single query? · Issue #8 · php-coder/query2app · GitHub
Open Graph Title: How to use path params and body in a single query? · Issue #8 · php-coder/query2app
X Title: How to use path params and body in a single query? · Issue #8 · php-coder/query2app
Description: In the current approach, we pass parameters to SQL query only from a single source (path params or body params): GET: uses path params POST: uses body params PUT: uses body params DELETE: uses path params But even for a simple PUT endpoi...
Open Graph Description: In the current approach, we pass parameters to SQL query only from a single source (path params or body params): GET: uses path params POST: uses body params PUT: uses body params DELETE: uses path...
X Description: In the current approach, we pass parameters to SQL query only from a single source (path params or body params): GET: uses path params POST: uses body params PUT: uses body params DELETE: uses path...
Opengraph URL: https://github.com/php-coder/query2app/issues/8
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"How to use path params and body in a single query?","articleBody":"In the current approach, we pass parameters to SQL query only from a single source (path params or body params):\r\n- GET: uses path params\r\n- POST: uses body params\r\n- PUT: uses body params\r\n- DELETE: uses path params\r\n\r\nBut even for a simple `PUT` endpoint it isn't enough: we want to extract object ID from a path and other parameters from a body. Here is an example of generated code that we should improve:\r\n```js\r\napp.put('/v1/categories/:categoryId', (req, res) => {\r\n pool.query(\r\n 'UPDATE categories SET name = :name , name_ru = :nameRu , slug = :slug , updated_at = NOW() , updated_by = :userId WHERE id = :categoryId',\r\n { \"name\": req.body.name, \"nameRu\": req.body.nameRu, \"slug\": req.body.slug, \"userId\": req.body.userId, \"categoryId\": req.body.categoryId },\r\n```\r\nWe can see that `categoryId` is bound to `req.body.categoryId` while it should use a value from `req.params.categoryId`.\r\n\r\nAlso there will be more cases where we need to combine different sources: userId might be extracted from a header. We might want to access cookies or query parameters.","author":{"url":"https://github.com/php-coder","@type":"Person","name":"php-coder"},"datePublished":"2020-07-15T18:17:32Z","url":"https://github.com/php-coder/query2app/issues/8"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7f407d97-4ff6-aaf4-ea67-b370d4e88705 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E7D4:262104:112871:178B14:6AFE34DD |
| html-safe-nonce | f4d61abfcb6be5ada61bbad7310d8e62fcb88b9c9b23c775179203f1eb4ab399 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFN0Q0OjI2MjEwNDoxMTI4NzE6MTc4QjE0OjZBRkUzNEREIiwidmlzaXRvcl9pZCI6IjUyNTc4MzM4NDk1NTkwNjk5MTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | efddf235a130f71ef32dabeaa65e1fd89e3477c615d5185700a8b1ab7f5b1830 |
| hovercard-subject-tag | issue:657555643 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/php-coder/query2app/8/issue_layout |
| twitter:image | https://opengraph.githubassets.com/97452d65d2e39997212302c183679072783b6e498c197513c2fef5670a764feb/php-coder/query2app/issues/8 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/97452d65d2e39997212302c183679072783b6e498c197513c2fef5670a764feb/php-coder/query2app/issues/8 |
| og:image:alt | In the current approach, we pass parameters to SQL query only from a single source (path params or body params): GET: uses path params POST: uses body params PUT: uses body params DELETE: uses path... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | php-coder |
| hostname | github.com |
| expected-hostname | github.com |
| None | d70e31220a67f6376c108d2416fa8e7df854c1065b1672ab7a88ab6dc3a809e2 |
| turbo-cache-control | no-preview |
| go-import | github.com/php-coder/query2app git https://github.com/php-coder/query2app.git |
| octolytics-dimension-user_id | 87088 |
| octolytics-dimension-user_login | php-coder |
| octolytics-dimension-repository_id | 279082426 |
| octolytics-dimension-repository_nwo | php-coder/query2app |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 279082426 |
| octolytics-dimension-repository_network_root_nwo | php-coder/query2app |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ccb88d9c92abe69245b429398c8a57ae87070c7c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width