kysely README

The project's README from github.com/kysely-org/kysely. As one markdown file: README.md.

Stand With Ukraine

NPM Version Socket Badge Tests License Issues Pull Requests GitHub contributors NPM Downloads JSR Downloads JSR Score

Join the discussion ⠀⠀⠀⠀⠀⠀⠀

Discord Bluesky

Get started

PostgreSQL MySQL MSSQL SQLite PGlite & more!

Kysely

Kysely (pronounce “Key-Seh-Lee”) is a type-safe and autocompletion-friendly TypeScript SQL query builder. Inspired by Knex.js. Mainly developed for Node.js but also runs on all other JavaScript environments like Deno, Bun, Cloudflare Workers and web browsers.

Kysely makes sure you only refer to tables and columns that are visible to the part of the query you're writing. The result type only has the selected columns with correct types and aliases. As an added bonus you get autocompletion for all that stuff.

As shown in the gif above, through the pure magic of modern TypeScript, Kysely is even able to parse the alias given to pet.name and add the pet_name column to the result row type. Kysely is able to infer column names, aliases and types from selected subqueries, joined subqueries, with statements and pretty much anything you can think of.

Of course there are cases where things cannot be typed at compile time, and Kysely offers escape hatches for these situations. See the sql template tag and the DynamicModule for more info.

All API documentation is written in the typing files and you can simply hover over the module, class or method you're using to see it in your IDE. The same documentation is also hosted here.

If you start using Kysely and can't find something you'd want to use, please open an issue or join our Discord server.

Getting started

Please visit our documentation site kysely.dev to get started. We also have a comprehensive API documentation hosted here, but you can access the same documentation in your IDE by hovering over a class/method/property/whatever.

Core team

Project leads

Responsible for project direction, API design, maintenance, code reviews, community support, documentation, and working on some of the most impactful/challenging things.


Sami Koskimäki

(the author)

Igal Klebanov

(the dynamo)

Honorable mentions

People who had special impact on the project and its growth.


Fernando Hurtado

(1st docs)

Wirekang

(playground)

Tim Griesser

(Knex)

Robin Blomberg

(codegen)

Shoubhit Dash

(prisma idea)

Valtýr Örn Kjartansson

(prisma impl)

Dax Raad

(early adopter)

Theo Browne

(early promoter)

Lee Robinson

(early promoter)

Ethan Resnick

(timely feedback)

Harminder Virk

(dope writeup)

Johan Eliasson

(promoter/educator)

All contributors


Want to contribute? Check out our contribution guidelines.

Powered by Vercel

kysely (kysely-org/kysely)

Searching Database…

14.3K ·GitHub
Что это такое?Kysely (произносится «Кей-Се-Ли») — это type-safe конструктор SQL-запросов для TypeScript с удобным автодополнением, созданный по мотивам Knex.js: он проверяет ваши запросы ещё на этапе компиляции и типизирует результаты.
То есть это библиотека, которую я добавляю в свой проект, а не утилита, которую запускаю?Именно так — библиотека. Вы пишете запросы в своём TypeScript-коде, Kysely собирает из них SQL, а возвращаемые строки полностью типизированы.
Где он работает — только Node.js?Основная платформа — Node.js (Node 22+ согласно метаданным пакета), но он также работает на Deno, Bun, Cloudflare Workers и в браузерах — и пакет не имеет runtime-зависимостей.
А если часть моего запроса нельзя типизировать на этапе компиляции?Для таких случаев в Kysely есть обходные пути: шаблонный тег sql для «сырого» SQL и DynamicModule для динамических ситуаций.
Мне нужен проект на TypeScript, чтобы это имело смысл?Да — он создан для TypeScript-проектов: проверки на этапе компиляции и автодополнение работают благодаря статическим типам. Технически его можно вызывать из обычного JavaScript, но тогда вы потеряете типобезопасность — а в ней весь смысл.
Что типобезопасность даёт мне на практике?Гарантии на этапе компиляции: вы можете ссылаться только на таблицы и колонки, доступные в данной точке запроса, а тип результата содержит ровно выбранные колонки с корректными типами и алиасами — плюс автодополнение прямо во время написания кода.
Насколько он умно обращается с алиасами и подзапросами?Очень: он разбирает алиас вроде pet.name в типизированную колонку petname в строке результата, а имена колонок, алиасы и типы выводит из обычных подзапросов, подзапросов в JOIN и with-конструкций.
Какие базы данных он поддерживает?В темах репозитория указаны PostgreSQL, MySQL, SQLite и Microsoft SQL Server (MSSQL).
Как произносится название?«Кей-Се-Ли» — README фиксирует это в первой же строке.
What are similar projects?sequelize, orm, typeorm, directus, diesel, efcore, pglite, remix
Creator
kysely-org
Size
58.2 MB
Stars
14.3K
Age
5y
Commits · 90 Days