Pie Logo
Quiz: Prisma and ORM
by Tomas Trescak

QuizTest your understanding of the section content.

ContentDetailed description of the section content.

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
    Quiz: Prisma and ORM
    by Tomas Trescak

    QuizTest your understanding of the section content.

    ContentDetailed description of the section content.

    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

    Prisma and ORM
    by Tomas Trescak· Prisma and ORM

    QUESTION 1

    A user visits /posts/tech and expects to see tech posts from 2025. Here’s the code:

    const posts = await prisma.post.findMany({
      where: {
        tags: { some: { name: "tech" } },
        date: { gte: new Date("2025-01-01") },
      },
      include: { tags: true },
    });
    

    What changes would make this code also limit results to posts before March 31, 2025?


    QUESTION 2

    An admin wants to add a post titled "Spring Update" with tags "news" and "updates." The code is:

    const post = await prisma.post.create({
      data: {
        title: "Spring Update",
        content: "New season!",
        date: new Date(),
        tags: { connect: [{ name: "news" }, { name: "updates" }] },
      },
    });
    

    What happens if the "updates" tag doesn’t exist yet in the database?


    QUESTION 3

    You’re debugging the blogging app. A user reports that /posts/news shows no posts, even though news posts exist. Here’s the code:

    const posts = await prisma.post.findMany({
      where: {
        tags: { some: { name: "News" } },
        date: { gte: new Date("2025-02-01") },
      },
    });
    

    What could be causing this? (Select all that apply)


    QUESTION 4

    The admin wants to update a post’s title and add a new tag "featured" that doesn’t exist yet. Which code snippet works best?


    QUESTION 5

    For the client-side route /posts/recent, you want the 5 most recent posts. How would you modify this code?

    const posts = await prisma.post.findMany();
    

    (Select all that apply)

    This content is only available to registered users.
    Please register at the the home page.

    Prisma and ORM
    by Tomas Trescak· Prisma and ORM

    QUESTION 1

    A user visits /posts/tech and expects to see tech posts from 2025. Here’s the code:

    const posts = await prisma.post.findMany({
      where: {
        tags: { some: { name: "tech" } },
        date: { gte: new Date("2025-01-01") },
      },
      include: { tags: true },
    });
    

    What changes would make this code also limit results to posts before March 31, 2025?


    QUESTION 2

    An admin wants to add a post titled "Spring Update" with tags "news" and "updates." The code is:

    const post = await prisma.post.create({
      data: {
        title: "Spring Update",
        content: "New season!",
        date: new Date(),
        tags: { connect: [{ name: "news" }, { name: "updates" }] },
      },
    });
    

    What happens if the "updates" tag doesn’t exist yet in the database?


    QUESTION 3

    You’re debugging the blogging app. A user reports that /posts/news shows no posts, even though news posts exist. Here’s the code:

    const posts = await prisma.post.findMany({
      where: {
        tags: { some: { name: "News" } },
        date: { gte: new Date("2025-02-01") },
      },
    });
    

    What could be causing this? (Select all that apply)


    QUESTION 4

    The admin wants to update a post’s title and add a new tag "featured" that doesn’t exist yet. Which code snippet works best?


    QUESTION 5

    For the client-side route /posts/recent, you want the 5 most recent posts. How would you modify this code?

    const posts = await prisma.post.findMany();
    

    (Select all that apply)

    This content is only available to registered users.
    Please register at the the home page.

    Pie Logo
    Quiz: Prisma and ORM
    by Tomas Trescak
    Pie Logo
    Quiz: 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