Back to articles
Kysely Has a Free API — The Type-Safe SQL Query Builder for TypeScript
How-ToSystems

Kysely Has a Free API — The Type-Safe SQL Query Builder for TypeScript

via Dev.to TutorialAlex Spinov

Kysely is a type-safe SQL query builder for TypeScript. Unlike ORMs that abstract away SQL, Kysely lets you write SQL — with full autocompletion and compile-time type checking. Why Kysely? SQL, not ORM — write SQL you understand, get types you trust Full autocompletion — table names, column names, joins — all typed Zero runtime overhead — just builds SQL strings Any database — PostgreSQL, MySQL, SQLite, D1, PlanetScale Quick Start npm install kysely pg import { Kysely , PostgresDialect } from ' kysely ' ; import { Pool } from ' pg ' ; interface Database { users : { id : number ; name : string ; email : string ; created_at : Date ; }; posts : { id : number ; title : string ; content : string ; author_id : number ; }; } const db = new Kysely < Database > ({ dialect : new PostgresDialect ({ pool : new Pool ({ connectionString : process . env . DATABASE_URL }), }), }); CRUD Operations // Select const users = await db . selectFrom ( ' users ' ) . selectAll () . where ( ' email ' , ' like '

Continue reading on Dev.to Tutorial

Opens in a new tab

Read Full Article
3 views

Related Articles