Skip to content

A postgres & mysql -> typescript interface generator

License

Notifications You must be signed in to change notification settings

vramework/schemats

Repository files navigation

Schemats

Before anything, I would like to give a massive thank you to sweetiq and their contributors for giving me a huge head start.

The reason I have created a new repo instead of a fork is because I don't support mysql and have some breaking changes due to how this library is consumed by postgres-typed and vramework.

I have kept the name and based off their MIT license as means of attribution and thanks.

Why Schemats

Because being able to make a change to your database structure and have it:

  • validate through your node backend APIs
  • get verified against automatically generate JSON schemas
  • raise errors in your frontend application

Is just a great developer experience in my opinion.

This allows us to some pretty amazing things when it comes to refactoring and maintaining codebases, and also provide the meta-data to help with libraries like postgres-typed.

Quickstart

Installing

yarn add -d @vramework/schemats || npm install -d @vramework/schemats

Generating the type definition from schema

Assuming you have the following schema (this is a bit of a random one):

CREATE SCHEMA "pet_store";

CREATE TYPE "pet_store"."animal" AS enum (
  'cat',
  'dog'
);

CREATE TABLE "pet_store".