The code in this repo demonstrates use of prisma as an ORM using two tables with geography data sets (continents and countries).
This code uses the following libaries:
- prisma
- typescript
- express
- postgresql
- prisma-repo - generate repositories and models
This code assumes usage of prisma requires typescript
This proof of concept uses a repository to get data from database and uses express.
To get started perform the following steps:
https://www.postgresql.org/download/
After installing locally you should have a database server - you will need to do these steps:
Install the required packages via standard command:
npm install
The database schema creation is managed by prisma migrations. The initial migrations file is under prisma/migrations folder.
To setup the database run npm run db:migrations
See more: https://www.prisma.io/docs/concepts/components/prisma-migrate/migrate-development-production
The data in the database is setup via "seeding"
See file prisma/runSeeders.ts
run npm run db:seed
to populate the database
See More:
https://www.prisma.io/docs/guides/database/seed-database
The application is configured to use nodemon to monitor for file changes and you can run command to start the application using it. You will see console information with url and port.
npm run start
-
https://www.getpostman.com - Download and install https://www.getpostman.com
Use the client of your choice to run the requests to see api data and responses after importing the collection in the "postman" folder