How to add type definitions for includes in a Prisma model?

방법 1

Prisma를 import한 후 MODELGetPayload를 사용함

아래는 Product 모델을 검색할 때 관계된 User 모델을 포함한 결과의 타입 선언

import type { Prisma } from "@prisma/client";

type ProductsIdResponse = {
  ok: boolean;
  product: Prisma.ProductGetPayload<{
    include: {
      user: true;
    };
  }>;
};

방법 2

interface + extends를 사용해서 타입 정의하여 사용

import type { Product, User } from "@prisma/client";

interface ProductWithUser extends Product {
  user: User;
}

type ProductsIdResponse = {
  ok: boolean;
  product: ProductWithUser;
};