https://github.com/barelyhuman/knex-types
Auto Generate Types for your database schema from your knex instance.
https://github.com/barelyhuman/knex-types
autogenerate database generate knex models types typescript
Last synced: 5 months ago
JSON representation
Auto Generate Types for your database schema from your knex instance.
- Host: GitHub
- URL: https://github.com/barelyhuman/knex-types
- Owner: barelyhuman
- License: mit
- Created: 2024-03-26T18:10:10.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-25T06:36:07.000Z (about 2 years ago)
- Last Synced: 2025-10-07T19:56:32.271Z (9 months ago)
- Topics: autogenerate, database, generate, knex, models, types, typescript
- Language: JavaScript
- Homepage:
- Size: 305 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# @barelyhuman/knex-types
> Generate Model types from Knex
- [@barelyhuman/knex-types](#barelyhumanknex-types)
- [Schema Support](#schema-support)
- [Usage](#usage)
- [License](#license)
## 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.
- [x] Sqlite
- [ ] Postgres (Partial)
- [ ] MSSQL (Partial)
- [ ] Oracle (Partial)
## Usage
```js
// in CJS
const { generateTypes } = require("@barelyhuman/knex-types");
const knexInstance = knex(config);
generateTypes(knexInstance, {
output: "./types.d.ts",
}).then((d) => {
// Done
});
```
```js
// in ESM
import { generateTypes } from "@barelyhuman/knex-types";
const knexInstance = knex(config);
await generateTypes(knexInstance, {
output: "./types.d.ts",
});
```
## License
[MIT](/LICENSE)