This is a fairly small example app, but we feel like we've done a good job of stressing the capabilities of Prisma interactions in such a way that we need to break the rules.
The app is a league - game tracker. So, games have a game time + home team + away team. Simple, uh?
We complicated the app-to-database connection in a few ways:
- Time zone complication. When querying, for a specific date a person in Europe has a different "day" than a person in Asia. Thus, the views, app, and database all have to agree how dates will be managed.
- As of the creation of this application, you cannot pass SQL functions to a Prisma select. Thus, to extract the unique days from the datetime game values, it is fastest to use raw SQL.
Additionally, we added some good best-practices to this application:
- Enhanced Postgres logging. We want to see the queries that Prisma generates and executes.
- Pull down repo
- Install libraries:
npm install
- Run Postgres:
initdb -D data; postgres -D data
- Run Prisma migrations:
npx prisma db push
- Seed data:
node --require esbuild-register prisma/seed.ts
- Run development:
npm run dev
- Open app in your browser: http://localhost:3000/games