Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattwelke/typeorm-postgres-example
An example showing using TypeORM with PostgreSQL, including a seed task.
https://github.com/mattwelke/typeorm-postgres-example
Last synced: about 2 months ago
JSON representation
An example showing using TypeORM with PostgreSQL, including a seed task.
- Host: GitHub
- URL: https://github.com/mattwelke/typeorm-postgres-example
- Owner: mattwelke
- License: unlicense
- Archived: true
- Created: 2018-01-22T22:12:25.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2024-01-15T17:49:41.000Z (12 months ago)
- Last Synced: 2024-06-18T15:43:22.606Z (7 months ago)
- Language: TypeScript
- Size: 642 KB
- Stars: 127
- Watchers: 4
- Forks: 18
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# typeorm-postgres-example
> [!NOTE]
> Example is complete and will not receive future updates.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.
1. Run `docker-compose up -d` to create and start the required Docker containers for the PostgreSQL database.
1. Run `npm run build` to compile the code, including tasks.
1. 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.
1. 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.
1. Run `npm start` to start the app.