-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update site examples to use updated expression builder
- Loading branch information
Showing
11 changed files
with
116 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const complexValues = `const result = await db | ||
.updateTable('person') | ||
.set((eb) => ({ | ||
age: eb('age', '+', 1), | ||
first_name: eb.selectFrom('pet').select('name').limit(1), | ||
last_name: 'updated', | ||
})) | ||
.where('id', '=', '1') | ||
.executeTakeFirst() | ||
console.log(result.numUpdatedRows)` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
title: 'Complex values' | ||
--- | ||
|
||
# Complex values | ||
|
||
As always, you can provide a callback to the `set` method to get access | ||
to an expression builder: | ||
|
||
import { | ||
Playground, | ||
exampleSetup, | ||
} from '../../../src/components/Playground' | ||
|
||
import { | ||
complexValues | ||
} from './0020-complex-values' | ||
|
||
<div style={{ marginBottom: '1em' }}> | ||
<Playground code={complexValues} setupCode={exampleSetup} /> | ||
</div> | ||
|
||
:::info More examples | ||
The API documentation is packed with examples. The API docs are hosted [here](https://kysely-org.github.io/kysely/) | ||
but you can access the same documentation by hovering over functions/methods/classes in your IDE. The examples are always | ||
just one hover away! | ||
|
||
For example, check out these sections: | ||
- [set method](https://kysely-org.github.io/kysely/classes/UpdateQueryBuilder.html#set) | ||
- [returning method](https://kysely-org.github.io/kysely/classes/UpdateQueryBuilder.html#returning) | ||
- [updateTable method](https://kysely-org.github.io/kysely/classes/Kysely.html#updateTable) | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
export const orWhere = `const persons = await db | ||
.selectFrom('person') | ||
.selectAll() | ||
.where(({ or, and, cmpr }) => or([ | ||
and([ | ||
cmpr('first_name', '=', 'Jennifer'), | ||
cmpr('last_name', '=', 'Aniston') | ||
]), | ||
and([ | ||
cmpr('first_name', '=', 'Sylvester'), | ||
cmpr('last_name', '=', 'Stallone') | ||
]) | ||
// 1. Using the \`or\` method on the expression builder: | ||
.where((eb) => eb.or([ | ||
eb('first_name', '=', 'Jennifer'), | ||
eb('first_name', '=', 'Sylvester') | ||
])) | ||
// 2. Chaining expressions using the \`or\` method on the | ||
// created expressions: | ||
.where((eb) => | ||
eb('last_name', '=', 'Aniston').or('last_name', '=', 'Stallone') | ||
) | ||
.execute()` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7b83f8f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
kysely – ./
www.kysely.dev
kysely.dev
kysely-kysely-team.vercel.app
kysely-git-master-kysely-team.vercel.app