Skip to main content

Built and signed on GitHub Actions

Generate Model types from Knex

This package works with Node.jsIt is unknown whether this package works with Cloudflare Workers, Deno, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
70%
Published
6 months ago (0.0.5)

@barelyhuman/knex-types

Generate Model types from Knex

Schema Support

While the below checklist mentions Partial, most of what the library can generate should be usable. It says partial because things like enum and other constraints that can be used to generate better types and models for knex are still not done.

  • Sqlite
  • Postgres (Partial)
  • MSSQL (Partial)
  • Oracle (Partial)

Usage

// in CJS
import { generateTypes } from "@barelyhuman/knex-types";
const knexInstance = knex(config);

generateTypes(knexInstance, {
  output: "./types.d.ts",
}).then((d) => {
  // Done
});
// in ESM
import { generateTypes } from "@barelyhuman/knex-types";
const knexInstance = knex(config);
await generateTypes(knexInstance, {
  output: "./types.d.ts",
});

License

MIT

Built and signed on
GitHub Actions
View transparency log

Add Package

deno add jsr:@barelyhuman/knex-types

Import symbol

import * as mod from "@barelyhuman/knex-types";

---- OR ----

Import directly with a jsr specifier

import * as mod from "jsr:@barelyhuman/knex-types";

Add Package

npx jsr add @barelyhuman/knex-types

Import symbol

import * as mod from "@barelyhuman/knex-types";

Add Package

yarn dlx jsr add @barelyhuman/knex-types

Import symbol

import * as mod from "@barelyhuman/knex-types";

Add Package

pnpm dlx jsr add @barelyhuman/knex-types

Import symbol

import * as mod from "@barelyhuman/knex-types";

Add Package

bunx jsr add @barelyhuman/knex-types

Import symbol

import * as mod from "@barelyhuman/knex-types";