Kysely
이 내용은 아직 번역본이 없습니다.
Kysely is a type-safe and autocompletion-friendly TypeScript SQL query builder.
It lets developers build SQL queries with a fluent API. It also helps to detect errors in queries by leveraging TypeScript.
A Little Case
In the following example, we use the Kysely query builder to fetch a user from the database:
Kysely uses the DB
interface to type the result of the query. As a consequence, TypeScript infers the user
variable as User | undefined
(because the query may return an empty result).
Kysely helps to type the query result, and also the query itself. For example, if we try to select a column foo
that does not exist in the user
type, we will have a TypeScript error:
The error message is not very clear, but it helps to detect the bug and prevent runtime errors.
More Features In The Video
Useful Resources
- Kysely Docs https://kysely.dev/docs/intro
- Kysely GitHub https://github.com/kysely-org/kysely
- Kysely API Docs https://kysely-org.github.io/kysely-apidoc/
- Kysely Code Examples https://kysely.dev/docs/category/examples