Type safety problem of Knex query builder

This page summarizes the projects mentioned and recommended in the original post on /r/node

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • Knex

    A query builder for PostgreSQL, MySQL, CockroachDB, SQL Server, SQLite3 and Oracle, designed to be flexible, portable, and fun to use.

  • Knex's TypeScript support is very weak. Type inference gets disabled in rather complex queries - even in simple joins. I want to have a strong type safety for response objects of my queries. My project size is "small-to-mid". Possible solutions in my mind:

  • kysely

    Discontinued A type-safe typescript SQL query builder [Moved to: https://github.com/kysely-org/kysely] (by koskimas)

  • If you like knex checkout kysely. It's basically knex built on typescript https://github.com/koskimas/kysely

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • pgtyped

    pgTyped - Typesafe SQL in TypeScript

  • If you would like to use raw SQL, pgtyped looks rather interesting although it only supports postgres. https://github.com/adelsz/pgtyped

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts