Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] Update complex join example to better illustrate the options available (symmetry with where) #883

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"chai-as-promised": "^7.1.1",
"chai-subset": "^1.6.0",
"esbuild": "^0.19.11",
"lodash": "^4.17.21",
"mocha": "^10.2.0",
"mysql2": "^3.6.5",
"pg": "^8.11.3",
Expand Down
1 change: 1 addition & 0 deletions site/docs/examples/JOIN/0030-complex-join.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const complexJoin = `await db.selectFrom('person')
(join) => join
.onRef('pet.owner_id', '=', 'person.id')
.on('pet.name', '=', 'Doggo')
.on((eb) => eb.or([eb("person.age", ">", 18), eb("person.age", "<", 100)]))
)
.selectAll()
.execute()`
6 changes: 4 additions & 2 deletions site/docs/examples/JOIN/0030-complex-join.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ You can provide a function as the second argument to get a join
builder for creating more complex joins. The join builder has a
bunch of `on*` methods for building the `on` clause of the join.
There's basically an equivalent for every `where` method
(`on`, `onRef` etc.). You can do all the same things with the
`on` method that you can with the corresponding `where` method.
(`on`, `onRef` etc.).

You can do all the same things with the
`on` method that you can with the corresponding `where` method (like [OR expressions for example](https://kysely.dev/docs/examples/WHERE/or-where)).
See the `where` method documentation for more examples.

import {
Expand Down
7 changes: 5 additions & 2 deletions src/query-builder/select-query-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,10 @@ export interface SelectQueryBuilder<DB, TB extends keyof DB, O>
* builder for creating more complex joins. The join builder has a
* bunch of `on*` methods for building the `on` clause of the join.
* There's basically an equivalent for every `where` method
* (`on`, `onRef` etc.). You can do all the same things with the
* `on` method that you can with the corresponding `where` method.
* (`on`, `onRef` etc.).
*
* You can do all the same things with the
* `on` method that you can with the corresponding `where` method (like [OR expressions for example](https://kysely.dev/docs/examples/WHERE/or-where)).
* See the `where` method documentation for more examples.
*
* ```ts
Expand All @@ -591,6 +593,7 @@ export interface SelectQueryBuilder<DB, TB extends keyof DB, O>
* (join) => join
* .onRef('pet.owner_id', '=', 'person.id')
* .on('pet.name', '=', 'Doggo')
* .on((eb) => eb.or([eb("person.age", ">", 18), eb("person.age", "<", 100)]))
* )
* .selectAll()
* .execute()
Expand Down
Loading