UNPKG

@phyng/typeschema

Version:

A database schema definition library using TypeScript or JSON

42 lines (30 loc) 900 B
# TypeSchema A database schema definition library using TypeScript or JSON [![npm](https://img.shields.io/npm/v/@phyng/typeschema)](https://www.npmjs.com/package/@phyng/typeschema) [![docs](https://img.shields.io/badge/docs-phyng.com-blue)](https://phyng.com/typeschema/) ## install ```bash # use pnpm pnpm add @phyng/typeschema # or use npm npm install @phyng/typeschema ``` ## Usage ```ts import { Db, Table, Field } from '@phyng/typeschema' const db = Db([ Table('user', [ Field('id', 'int', { pk: true, increment: true }), Field('username', 'string'), Field('name', 'string', { null: true }), ]), Table('post', [ Field('id', 'int', { pk: true, increment: true }), Field('name', 'string'), Field('content', 'string'), ]), ]) export default db ``` ## License This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.