Pie Logo
Exercise: Prisma and ORM
by Tomas Trescak

ContentDetailed description of the section content.

Installation

We will continue using the same project as in your tutorials and previous lectures in this section and the following sections. Please download it from your forked repository (instructions here )

Instructions

  1. Complete all the user requirements below
  2. Cover each user requirement by end-to-end test (tag each test by “@prisma”)
  3. If necessary, cover utility code and component code with unit or integration tests
  4. Commit and push the code
  5. Make sure all tests pass
  6. Commit and push your code to your repository

Setup

In this section, we will play with Prisma , please install both needed packages:

pnpm i prisma @prisma/client

You will also need access to a Mongodb and Postgres database. We recommend you create an account with Mongodb and Vercel or Neon:

Prisma Schema

Please use this schema:

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "sqlite"
  url      = env("DATABASE_URL")
}

model Post {
  id        Int      @id @default(autoincrement())
  title     String
  content   String
  date      DateTime
  tags      Tag[]    @relation("PostTags")
}
 
model Tag {
  id        Int      @id @default(autoincrement())
  name      String   @unique
  posts     Post[]   @relation("PostTags")
}

System Requirements

All branches:

  1. Cache database requests with 1 hour update interval
  2. Preload blog post when hovering over the link

Git Branch - “Main”

  1. I want to obtain the list of posts from the database using Prisma
  2. I want to obtain a filtered list of posts from database based on tags using Prisma
  3. I want to show the list of available tags using Prisma
  4. I want to obtain a filtered list of posts from the database based on tags
  5. I want to show the list of available tags
  6. I want to be able to like the post
  7. I want to update post
Full Stack Development
Introduction
Generative AI
🍰 Player
💼 Editor
Setup
React Fundamentals
Next.js
Advanced React
Databases
Fetching Data
SQL vs No-SQL Databases
Prisma and ORM
Exercise: Prisma and ORM
Quiz: Prisma and ORM
Seeding and Migrations
Search and Pagination
Server Actions
Client-Side Mutations
Validations and Error Handling
Assignment 2.2: Blog - Admin
React Hooks
Authentication and Authorisation
APIs
CI/CD and DevOps
Testing React
Advanced Topics
    Pie Logo
    Exercise: Prisma and ORM
    by Tomas Trescak

    ContentDetailed description of the section content.

    Installation

    We will continue using the same project as in your tutorials and previous lectures in this section and the following sections. Please download it from your forked repository (instructions here )

    Instructions

    1. Complete all the user requirements below
    2. Cover each user requirement by end-to-end test (tag each test by “@prisma”)
    3. If necessary, cover utility code and component code with unit or integration tests
    4. Commit and push the code
    5. Make sure all tests pass
    6. Commit and push your code to your repository

    Setup

    In this section, we will play with Prisma , please install both needed packages:

    pnpm i prisma @prisma/client

    You will also need access to a Mongodb and Postgres database. We recommend you create an account with Mongodb and Vercel or Neon:

    Prisma Schema

    Please use this schema:

    // This is your Prisma schema file,
    // learn more about it in the docs: https://pris.ly/d/prisma-schema
    
    // Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
    // Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
    
    generator client {
      provider = "prisma-client-js"
    }
    
    datasource db {
      provider = "sqlite"
      url      = env("DATABASE_URL")
    }
    
    model Post {
      id        Int      @id @default(autoincrement())
      title     String
      content   String
      date      DateTime
      tags      Tag[]    @relation("PostTags")
    }
     
    model Tag {
      id        Int      @id @default(autoincrement())
      name      String   @unique
      posts     Post[]   @relation("PostTags")
    }

    System Requirements

    All branches:

    1. Cache database requests with 1 hour update interval
    2. Preload blog post when hovering over the link

    Git Branch - “Main”

    1. I want to obtain the list of posts from the database using Prisma
    2. I want to obtain a filtered list of posts from database based on tags using Prisma
    3. I want to show the list of available tags using Prisma
    4. I want to obtain a filtered list of posts from the database based on tags
    5. I want to show the list of available tags
    6. I want to be able to like the post
    7. I want to update post
    Full Stack Development
    Introduction
    Generative AI
    🍰 Player
    💼 Editor
    Setup
    React Fundamentals
    Next.js
    Advanced React
    Databases
    Fetching Data
    SQL vs No-SQL Databases
    Prisma and ORM
    Exercise: Prisma and ORM
    Quiz: Prisma and ORM
    Seeding and Migrations
    Search and Pagination
    Server Actions
    Client-Side Mutations
    Validations and Error Handling
    Assignment 2.2: Blog - Admin
    React Hooks
    Authentication and Authorisation
    APIs
    CI/CD and DevOps
    Testing React
    Advanced Topics
    Pie Logo
    Exercise: Prisma and ORM
    by Tomas Trescak
    Pie Logo
    Exercise: Prisma and ORM
    by Tomas Trescak
    Full Stack Development
    Introduction
    Generative AI
    🍰 Player
    💼 Editor
    Setup
    React Fundamentals
    Next.js
    Advanced React
    Databases
    Fetching Data
    SQL vs No-SQL Databases
    Prisma and ORM
    Exercise: Prisma and ORM
    Quiz: Prisma and ORM
    Seeding and Migrations
    Search and Pagination
    Server Actions
    Client-Side Mutations
    Validations and Error Handling
    Assignment 2.2: Blog - Admin
    React Hooks
    Authentication and Authorisation
    APIs
    CI/CD and DevOps
    Testing React
    Advanced Topics
    Full Stack Development
    Introduction
    Generative AI
    🍰 Player
    💼 Editor
    Setup
    React Fundamentals
    Next.js
    Advanced React
    Databases
    Fetching Data
    SQL vs No-SQL Databases
    Prisma and ORM
    Exercise: Prisma and ORM
    Quiz: Prisma and ORM
    Seeding and Migrations
    Search and Pagination
    Server Actions
    Client-Side Mutations
    Validations and Error Handling
    Assignment 2.2: Blog - Admin
    React Hooks
    Authentication and Authorisation
    APIs
    CI/CD and DevOps
    Testing React
    Advanced Topics