Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 2 days 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 (6 months ago)
- Default Branch: main
- Last Pushed: 2024-06-25T06:36:07.000Z (3 months ago)
- Last Synced: 2024-08-29T01:48:43.297Z (about 1 month ago)
- Topics: autogenerate, database, generate, knex, models, types, typescript
- Language: JavaScript
- Homepage:
- Size: 305 KB
- Stars: 1
- Watchers: 3
- 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)