https://github.com/kriasoft/knex-types
Generate TypeScript definitions (types) from a PostgreSQL database schema.
https://github.com/kriasoft/knex-types
database database-schema definitions graphql javascript knex knexjs nodejs pg postgres postgresql schema strongly-typed types typescript
Last synced: 2 months ago
JSON representation
Generate TypeScript definitions (types) from a PostgreSQL database schema.
- Host: GitHub
- URL: https://github.com/kriasoft/knex-types
- Owner: kriasoft
- License: mit
- Created: 2021-04-14T11:30:01.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-08-16T07:29:47.000Z (10 months ago)
- Last Synced: 2024-10-30T00:55:25.397Z (7 months ago)
- Topics: database, database-schema, definitions, graphql, javascript, knex, knexjs, nodejs, pg, postgres, postgresql, schema, strongly-typed, types, typescript
- Language: TypeScript
- Homepage:
- Size: 3.68 MB
- Stars: 65
- Watchers: 5
- Forks: 21
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Knex.js types generator
[](https://www.npmjs.com/package/knex-types)
[](https://www.npmjs.com/package/knex-types)
[](http://www.typescriptlang.org/)
[](http://patreon.com/koistya)
[](https://discord.gg/bSsv7XM)An utility module for [Knex.js](https://knexjs.org/) that generates TypeScript
definitions (types) from a PostgreSQL database schema.```
$ npm install knex
$ npm install knex-types --dev
```## Usage Example
```js
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`](./main.test.ts).
## Related Projects
- [GraphQL API Starter Kit](https://github.com/kriasoft/graphql-starter) — monorepo template, pre-configured with TypeScript, GraphQL.js, React, and Relay
- [Node.js API Starter Kit](https://github.com/kriasoft/node-starter-kit) — Node.js project template (PostgreSQL, Knex, OAuth 2.0, emails, Cloud Functions)## How to Contribute
Please create a [PR](https://docs.github.com/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request) or send me a message on [Discord](https://discord.gg/bSsv7XM).
## License
Copyright © 2021-present Kriasoft. This source code is licensed under the MIT license found in the
[LICENSE](https://github.com/kriasoft/knex-types/blob/main/LICENSE) file.---
Made with ♥ by Konstantin Tarkus ([@koistya](https://twitter.com/koistya), [blog](https://medium.com/@koistya))
and [contributors](https://github.com/kriasoft/knex-types/graphs/contributors).