Code Monkey home page Code Monkey logo

typeorm-postgres-example's Introduction

typeorm-postgres-example

Demonstrates using TypeORM with PostgreSQL in a Node app. It does not demonstrate creating the web app itself, except for a comment in the src/index.ts file showing where the app's "main" code would go. This example's purpose is to show how to set up a declarative development environment where team members (or you, in the future) would not need to run manual SQL commands for the local development database to match. Instead, the dbseed task (implemented as a TypeScript file compiled and executed by the build NPM task), takes care of ensuring the running database has the required SQL schema and that it is populated with test data.

System Prerequisites

  • Node 9.x+
  • Docker and docker-compose

Models

There are three models in this example:

  • Doctor
  • Patient
  • Appointment (junction model between Doctor and Patient)

First run

  1. Run npm install to install local dependencies.
  2. Run docker-compose up -d to create and start the required Docker containers for the PostreSQL database. Adminer is used for an easy way to access the database. (I'm not a big fan of pgAdmin4.)
  3. Run npm run build to compile the code, including tasks.
  4. Run npm run dbseed to insert the seed data into the running PostgreSQL database. Note that since the task is coded in TypeScript, it must be compiled first. Therefore, this npm script runs the build npm script first before running the dbseed task.

Next runs

These steps assume you have the docker-compose stack running.

After changing source code

  1. Run npm run build to compile the source code.
  2. Run npm start to start the app.

After changing seed data

  1. Run npm run dbseed to compile the source code and insert the seed data into the running PostgreSQL database.
  2. Run npm start to start the app.

typeorm-postgres-example's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar mattwelke avatar dependabot-support avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.