TypeORM & SQL View Example
Notes & Technology
This project demonstrates how to create and interact with a SQL view while using TypeORM.
Files of note:
src/entity/PetWithUpcomingAppointment.ts
src/migration/1541380756402-CreateView.ts
The code in this repository is written in Typescript, a superset of JavaScript. The scripts defined in package.json
use the ts-node
package to execute these files (more on that here). If you try to execute the files in ./src
directly with node, you're gonna have a bad time!
How To Get Running
- Run
npm i
command - Create a Postgres database named
vet_orm_dev
(Trycreatedb vet_orm_dev
from the command line) - Update database settings inside
ormconfig.json
file - Run
npm run seed
to populate your database - Run
npm run typeorm migration:run
to create the view - Run the
npm start
command to see the information from your view logged to the console!