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: fix values example not compiling. #1058

Merged
merged 1 commit into from
Jun 23, 2024
Merged
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
18 changes: 9 additions & 9 deletions site/docs/recipes/0010-extending-kysely.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Extending kysely

In many cases Kysely doesn't provide a built-in type-safe method for a feature. It's often because adding
that feature in a generic way that would work in all use cases would be really difficult or impossible.
In many cases, Kysely doesn't provide a built-in type-safe method for a feature. It's often because adding
that feature in a generic way that would work in all use cases is difficult or impossible.
In many cases it's better to create little helper functions in your project that suit your use case.
Kysely makes this really simple.
Kysely makes this simple.

The Kysely API is designed around two interfaces [`Expression<T>`](https://kysely-org.github.io/kysely-apidoc/interfaces/Expression.html)
and [`AliasedExpression<T, A>`](https://kysely-org.github.io/kysely-apidoc/interfaces/AliasedExpression.html).
Expand All @@ -21,7 +21,7 @@ that has a type `T` and a single method `toOperationNode()`. `T` tells Kysely's
the expression. `toOperationNode()` returns instructions on what SQL should be produced once the
expression is compiled.

Here's an example of a custom expression for `JSON` or `JSONB` values on postgres:
Here's an example of a custom expression for `JSON` or `JSONB` values on PostgreSQL:

```ts
import { Expression, Kysely, OperationNode, sql } from 'kysely'
Expand Down Expand Up @@ -297,11 +297,11 @@ function values<R extends Record<string, unknown>, A extends string>(
// whole thing. Note that we need to explicitly specify
// the alias type using `.as<A>` because we are using a
// raw sql snippet as the alias.
return sql`(values ${values})`.as<A>(aliasSql)
return sql<R>`(values ${values})`.as<A>(aliasSql)
}
```

There's a lot going on in this function, but it's all documented in the
A lot is going on in this function, but it's all documented in the
[sql template tag's documentation.](https://kysely-org.github.io/kysely-apidoc/interfaces/Sql.html)

Most of the time a helper like this would return either an instance of `RawBuilder` or
Expand Down Expand Up @@ -356,8 +356,8 @@ variables and a nice discoverable API.

You can override and extend Kysely's builder classes via [Typescript module augmentation](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation).

The following example adds an `addIdColumn` method to `CreateTableBuilder`, that helps
in adding a postgres uuid primary key column:
The following example adds an `addIdColumn` method to `CreateTableBuilder`, which helps
in adding a PostgreSQL UUID primary key column:

```ts
declare module 'kysely/dist/cjs/schema/create-table-builder' {
Expand All @@ -377,7 +377,7 @@ CreateTableBuilder.prototype.addIdColumn = function (
}
```

Now you can use `addIdColumn` seemlessly to create several tables with a uniform
Now you can use `addIdColumn` seamlessly to create several tables with a uniform
primary key definition:

```ts
Expand Down