• This repository has been archived on 15/Jan/2024
  • Stars
    star
    127
  • Rank 281,395 (Top 6 %)
  • Language
    TypeScript
  • License
    The Unlicense
  • Created over 6 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An example showing using TypeORM with PostgreSQL, including a seed task.

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 14.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 PostgreSQL database.
  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.

More Repositories

1

upload-file-to-backblaze-b2-from-browser-example

Demonstrates calling the b2_upload_file Backblaze B2 Cloud Storage API from a web browser using AJAX.
JavaScript
38
star
2

serverless-managed-dbs-examples

Examples showing connecting various cloud FaaS providers to various cloud managed database services.
JavaScript
11
star
3

rails-active-record-and-mongoid-example

An example Rails app demonstrating using both ActiveRecord and Mongoid, including an association between two models, User and Post, each stored in different databases.
Ruby
10
star
4

satellite-internet-simulation

Using Unity to simulate satellite internet coverage of the Earth's surface given different constellation layouts. Inspired by Starlink. WIP.
C#
6
star
5

github-actions-pubsub-emulator-example

Go
2
star
6

python-people-mastodon-import-creator

Python
2
star
7

example-react-server-views-typescript

Finished code for the "Strongly-Typed, Server-Rendered Views with React and TypeScript" blog post.
TypeScript
2
star
8

nginx-reverse-proxy-subdomain-example

Using Nginx as a reverse proxy to multiple apps differentiated by subdomain with a catch-all first block to 404 all non-matches.
Dockerfile
2
star
9

packt-book-bot

Bot that tweets and logs the Packt free eBook of the day in BigQuery daily.
Java
1
star
10

talk-serverless-toronto-gcp-intro

The complete code for the demos presented during my "Intro to Serverless on GCP" talk for Serverless Toronto.
HTML
1
star
11

apache-openwhisk-runtime-java-11

A custom Apache OpenWhisk runtime for Java to add support for Java 11+. Not affiliated with the Apache Software Foundation.
Java
1
star
12

apache-openwhisk-runtime-java-17

Experimental runtime for Apache OpenWhisk. Not considered production ready. Not affiliated with the Apache Software Foundation.
Java
1
star