Kanel

Generate Typescript types from Postgres

README

kanel


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.

_Note_: If you are migrating from v2, there are significant breaking changes. There is a breakdown in the documentation.

Usage


Install with:

  1. ```bash
  2. $ npm i -D kanel
  3. ```

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

  1. ```bash
  2. $ npx kanel
  3. ```

Programmatical usage


Example of running generation from code:

  1. ```typescript
  2. import { processDatabase } from 'kanel';
  3. import config from './kanelrc';

  4. async function run() {
  5.   await processDatabase(config);
  6. }

  7. run();
  8. ```

Example


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




Contributors



Made with contrib.rocks.