From 0588cc1c16c9f90a5e14dca8645ef3f3e78c274a Mon Sep 17 00:00:00 2001 From: Olivier Cavadenti Date: Sun, 7 Nov 2021 14:03:24 +0100 Subject: [PATCH] Add doc for Delete joins and using syntax in Postgres --- components/Sidebar.jsx | 1 + sections/builder.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/components/Sidebar.jsx b/components/Sidebar.jsx index d9d6fdd6..f7eeb4d2 100644 --- a/components/Sidebar.jsx +++ b/components/Sidebar.jsx @@ -127,6 +127,7 @@ export default class Sidebar extends Component {
  • upsert
  • update
  • del / delete
  • +
  • using
  • returning
  • transacting
  •   – forUpdate
  • diff --git a/sections/builder.js b/sections/builder.js index d104b849..664299e2 100644 --- a/sections/builder.js +++ b/sections/builder.js @@ -1962,6 +1962,37 @@ export default [ .where('title', 'Alice in Wonderland') .del(['id', 'title'], { includeTriggerModifications: true }) ` + }, + { + type: "text", + content: "For PostgreSQL, Delete statement with joins is both supported with classic 'join' syntax and 'using' syntax." + }, + { + type: "runnable", + content: ` + knex('accounts') + .where('activated', false) + .join('accounts', 'accounts.id', 'users.account_id') + .del() + ` + } + ] + }, + { + type: "method", + method: "using", + example: ".using(tableName|tableNames)", + description: "Can be used to define in PostgreSQL a delete statement with joins with explicit 'using' syntax. Classic join syntax can be used too.", + children: [ + { + type: "runnable", + content: ` + knex('accounts') + .where('activated', false) + .using('accounts') + .whereRaw('accounts.id = users.account_id') + .del() + ` } ] },