Skip to content

cunhaedu/typeorm-tree-entities

Repository files navigation

TypeORM Tree Entities

Learning how to work with tree entities in TypeORM

📌 Table of Contents

🚀 Features

  • Departments CRUD

📋 Database Model

In order to understand the entities, I've created the following database model:

👷 Installation

You need to install Node.js and Yarn first, then in order to clone the project via HTTPS, run this command:

git clone https://github.com/cunhaedu/typeorm-tree-entities.git

Install dependencies

yarn install

Or

npm install

Create your environment variables based on the examples of .env.example

cp .env.example .env

Setup a database

Install Postgres to create a database and create a database, then you should modify the .env and ormconfig.json with your credentials

🏃 Getting Started

Run the transactions in order to configure the database schema:

yarn typeorm migration:run

Run the following command in order to start the application in a development environment:

yarn dev

🏃 Build

Run the following command in order to convert the .ts file to .js file in a folder called dist:

yarn build

Run the following command in order to start the application in a production environment:

yarn start

Status Codes

Check the following status codes in this API:

Status Code Description
200 OK
400 BAD REQUEST
404 NOT FOUND
500 INTERNAL SERVER ERROR

📮 Faq

Question: What patterns of tree entities are used in this project?

Answer: For now, this project use just the closure-table, that are the best way to read and write tree relations. In future, it'll contain more use examples of another patterns.

Question: What are the technologies used in this project?

Answer: The technologies used in this project are NodeJS + Express Framework to handle the server and TypeORM

More...

To get more info, please see this section of typeorm documentation about tree entities.

About

Learn how to work with tree entities in TypeORM

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published