Generate TypeScript definitions (types) from a PostgreSQL database schema.
MIT License
Bot releases are visible (Hide)
feat
: Add support for int2
extension integer type (#26) — @cskeppstedtchore
: Upgrade dependencies (#27) — @koistyaPublished by koistya almost 3 years ago
Published by koistya about 3 years ago
options.suffix
option (#7) — @bhendersonPublished by koistya about 3 years ago
schema
and exclude
options (#2) — @erlinghaugstadupdateSchema(db, {
schema: ["public", "log"], // defaults to "public"
exclude: ["migrate", "migrate_lock"], // defaults to []
}
Allow to add a custom prefix; improve the supported type coverage.
updateTypes({
output: `./types.ts`,
// Inject a custom import at the top of the generated file
prefix: `import { PostgresInterval } from "postgres-interval";`
});
Drop generation of EntityRecord
types, use Knex.DbRecord<Entity>
instead.
An utility module for Knex.js that generates TypeScript definitions (types) from a PostgreSQL database schema.
$ npm install knex
$ npm install knex-types --dev
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
.