Skip to content

Commit

Permalink
Merge pull request #357 from OlivierCavadenti/delete-pg-4591
Browse files Browse the repository at this point in the history
Add doc for Delete joins and using syntax in Postgres
  • Loading branch information
OlivierCavadenti committed Nov 7, 2021
2 parents 074903f + 0588cc1 commit 2a383bc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/Sidebar.jsx
Expand Up @@ -130,6 +130,7 @@ export default class Sidebar extends Component {
<li><a href="#Builder-upsert">upsert</a></li>
<li><a href="#Builder-update">update</a></li>
<li><a href="#Builder-del / delete">del / delete</a></li>
<li><a href="#Builder-using">using</a></li>
<li><a href="#Builder-returning">returning</a></li>
<li><a href="#Builder-transacting">transacting</a></li>
<li>&nbsp;&nbsp;– <a href="#Builder-forUpdate">forUpdate</a></li>
Expand Down
31 changes: 31 additions & 0 deletions sections/builder.js
Expand Up @@ -2004,6 +2004,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()
`
}
]
},
Expand Down

0 comments on commit 2a383bc

Please sign in to comment.