genxdb

2.2.0 • Public • Published

GenXDB - The cli tool to generate models on different orms.


GenXDB logo

GenXDB is a command-line interface tool that is used to design and generate models easily and quickly
using the json format based on different orms such as TypeORM and Prisma


Development Setup

Prerequisites

  • Install Node.js which includes [Node Package Manager][npm]

Setting Up a Project

  • Create a file in the project root dir named genxdb.json.

  • Install GenXDB globally:

npm install -g genxdb
  • Run the application:
genxdb

Source file example

{
  "database": [
    {
      "name": "user",
      "columns": [
        {
          "name": "id",
          "type": "number"
        },
        {
          "name": "name",
          "type": "string"
        },
        {
          "name": "surname",
          "type": "string",
          "nullable": true
        },
        {
          "name": "status",
          "type": "boolean",
          "default": true
        },
        {
          "name": "email",
          "type": "string",
          "unique": true
        },
        {
          "name": "password",
          "type": "string"
        },
        {
          "name": "created_at",
          "type": "Date",
          "default": "CURRENT_TIMESTAMP"
        }
      ],
      "primary": "id",
      "relations": [
        {
          "table": "task",
          "relation": "1-N"
        }
      ]
    },
    {
      "name": "task",
      "columns": [
        {
          "name": "id",
          "type": "number"
        },
        {
          "name": "name",
          "type": "string",
          "length": 150
        }
      ],
      "primary": "id",
      "relations": [
        {
          "table": "user",
          "relation": "N-1"
        }
      ]
    },
    {
      "name": "role",
      "columns": [
        {
          "name": "id",
          "type": "number"
        },
        {
          "name": "name",
          "type": "string"
        }
      ],
      "primary": "id",
      "relations": [
        {
          "table": "user",
          "relation": "N-M"
        }
      ]
    }
  ]
}

Output files example

user.entity.ts

User entity

task.entity.ts

Task entity

role.entity.ts

Role entity

Relations

Name Type
One to one 1-1
One to many 1-N
Many to one N-1
Many to many N-M

Author

👤Rocco Bosio

Contributing

Contributions, issues and feature requests are welcome!

Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

License

Copyright © 2024 Rocco Bosio.

This project is MIT licensed.

Package Sidebar

Install

npm i genxdb

Weekly Downloads

0

Version

2.2.0

License

MIT

Unpacked Size

29 kB

Total Files

21

Last publish

Collaborators

  • fiido