kriasoft / knex-types

Generate TypeScript definitions (types) from a PostgreSQL database schema.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Knex.js types generator

NPM Version NPM Downloads TypeScript Donate Discord

An utility module for Knex.js that generates TypeScript definitions (types) from a PostgreSQL database schema.

$ npm install knex
$ npm install knex-types --dev

Usage Example

const { knex } = require("knex");
const { updateTypes } = require("knex-types");

const db = knex(require("./knexfile"));

updateTypes(db, { output: "./types.ts" }).catch((err) => {
  console.error(err);
  process.exit(1);
});

Find an example of generated types in ./main.test.ts.

Related Projects

How to Contribute

Please create a PR or send me a message on Discord.

License

Copyright © 2021-present Kriasoft. This source code is licensed under the MIT license found in the LICENSE file.


Made with ♥ by Konstantin Tarkus (@koistya, blog) and contributors.

About

Generate TypeScript definitions (types) from a PostgreSQL database schema.

License:MIT License


Languages

Language:TypeScript 90.2%Language:JavaScript 9.8%