Skip to main content

prisma-database-setup-mongodb

MongoDB Setup. Reference when using this Prisma feature.

설치로 이동

소스 정보

저장소
prisma/cursor-plugin
최근 소스 활동
2026년 2월 6일 14:17
감지된 SKILL.md 언어
영어
스타
10
포크
1

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

파일 탐색기
2 개 파일

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
name
prisma-database-setup-mongodb
description
MongoDB Setup. Reference when using this Prisma feature.
license
MIT
metadata
{"author":"prisma","version":"7.0.0"}
# MongoDB Setup **⚠️ WARNING: MongoDB is NOT supported in Prisma ORM v7.** Support for MongoDB is planned for a future v7 release. If you need MongoDB, you must use **Prisma ORM v6**. ## Prerequisites - MongoDB 4.2+ - Replica Set configured (required for transactions) - **Prisma ORM v6.x** ## 1. Schema Configuration (v6) In `prisma/schema.prisma`: ```prisma datasource db { provider = "mongodb" url = env("DATABASE_URL") } generator client { provider = "prisma-client-js" } ``` ### ID Field Requirement MongoDB models **must** have a mapped `_id` field using `@id` and `@map("_id")`, usually of type `String` with `auto()` and `db.ObjectId`. ```prisma model User { id String @id @default(auto()) @map("_id") @db.ObjectId email String @unique name String? } ``` ### Relations Relations in MongoDB expect IDs to be `db.ObjectId` type. ```prisma model Post { id String @id @default(auto()) @map("_id") @db.ObjectId author User @relation(fields: [authorId], references: [id]) authorId String @db.ObjectId } ``` ## 2. Environment Variable In `.env`: ```env DATABASE_URL="mongodb+srv://user:password@cluster.mongodb.net/mydb?retryWrites=true&w=majority" ``` ## Migrations vs Introspection - **No Migrations**: MongoDB is schema-less. `prisma migrate` commands **do not work**. - **db push**: Use `prisma db push` to sync indexes and constraints. - **db pull**: Use `prisma db pull` to generate schema from existing data (sampling). ## Common Issues ### "Transactions not supported" Ensure your MongoDB instance is a **Replica Set**. Standalone instances do not support transactions. Atlas clusters are replica sets by default. ### "Invalid ObjectID" Ensure fields referencing IDs are decorated with `@db.ObjectId` if the target is an ObjectID.
GitHub에서 보기