Kanel

Generate Typescript types from Postgres
GitHub
883
Created 5 years ago, last commit 3 days ago
44 contributors
877 commits
Stars added on GitHub, month by month
11
12
1
2
3
4
5
6
7
8
9
10
2023
2024
Stars added on GitHub, per day, on average
Yesterday
+2
Last week
+0.9
/day
Last month
+0.4
/day
Last 12 months
+0.5
/day
npmPackage on NPM
kanel
3.10.3
Monthly downloads on NPM
11
12
1
2
3
4
5
6
7
8
9
10
2023
2024
README

Kanel Logo Kanel Logo

Generate Typescript types from a live Postgres database.

This is for people who don't like ORM's but who do like intellisense and type checking for their database access code.

See the documentation here

Introduction to the idea is outlined here.

Usage

Install with:

$ npm i -D kanel

To run, make sure you are in a folder that has a .kanelrc.js configuration file and that your database is running, and type:

$ npx kanel

Programmatical usage

Example of running generation from code:

import { processDatabase } from "kanel";
import config from "./kanelrc";

async function run() {
  await processDatabase(config);
}

run();

Example

To see an example of the result, check out the /example folder. It uses the Sample Database from www.postgresqltutorial.com.


If you want to learn about how I use this together with tRPC to create end-to-end type safety with PostgreSQL as the source of truth, check out my course on Newline:



Contributors

Made with contrib.rocks.