{
  "id": 9365076,
  "title": "Building a Type-Safe Database Workflow With Kysely",
  "url": "https://urgent.news/2026/09/23/building-a-type-safe-database-workflow-with-kysely",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-23T14:00:44.000Z",
  "source": {
    "name": "HackerNoon",
    "slug": "hackernoon",
    "url": "https://hackernoon.com/building-a-type-safe-database-workflow-with-kysely?source=rss"
  },
  "original_language": "en",
  "account": "Kysely is a query builder that provides a safe database workflow for Node.js applications. It offers a middle ground between raw SQL and full-featured ORMs, allowing developers to write queries with TypeScript interfaces while avoiding issues like SQL injections and automatic migrations errors. To use Kysely, you first describe your schema using interfaces, and then instantiate a Kysely object with the appropriate dialect, such as PostgresDialect in this case. Generated columns automatically fill in database-specific values, like serial primary keys, preventing mistakes in code.\n\nQuerying data is straightforward, with the return type inferred from the selected columns. Typographical errors in column names result in build failures before executing any queries. Joining tables provides autocomplete suggestions for new columns, making the development process more efficient. Kysely also provides helpers like Selectable, Insertable, and Updateable, enabling service functions to have the right shapes without maintaining multiple nearly identical interfaces.\n\nTo ensure accurate schema descriptions, generated types can be created by installing and running kysely-codegen. This tool introspects the database and generates TypeScript interfaces based on the schema. It can be customized with options like --camel-case and --singularize. Once generated, the types should be committed to the repository to reflect schema changes.\n\nMigrations are also supported, with Kysely exposing a Migrator class. However, it is recommended to use the kysely-ctl CLI tool, which simplifies the migration process and mirrors Knex.js CLI commands. Once installed, kysely-ctl can be configured in a kysely.config.ts file, and migrations can be created using the kysely migrate:make command.",
  "summary": "Build a PostgreSQL workflow with Kysely, generated TypeScript types, and migrations to keep database queries aligned with schema changes.",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}