Prisma+MongoDB+Docker Prisma needs to perform transactions, which requires your MongoDB server to be run as a replica set
See original GitHub issueBug description
#prismaClient.ts
import { PrismaClient as PrismaClientMongoDb } from '../mongodb/generated/mongodb';
const mongodb = new PrismaClientMongoDb({
log: ['query', 'info'],
});
export { postgres, mongodb };
Here schema-mongodb.prisma
generator clientMongoDb {
provider = "prisma-client-js"
output = "./generated/mongodb"
}
datasource db {
provider = "mongodb"
url = env("DATABASE_URL_MONGODB")
}
model PageAccessCounter {
id String @id @default(auto()) @map("_id") @db.ObjectId
created_at DateTime @default(now())
updated_at DateTime @updatedAt
@@map("page_access_counters")
}
.env
DATABASE_URL_MONGODB="mongodb://root:tests123@127.0.0.1:27017/shoofertaecommerce?authSource=admin&retryWrites=true&w=majority&directConnection=true&ssl=false&&readPreference=primary&replicaSet=prefer"
follow error code: ‘P2031’,
await this.prismaRepository.pageAccessCounter.create(Prisma needs to perform transactions, which requires your MongoDB server to be run as a replica set.)
How to reproduce
Expected behavior
No response
Prisma information
database credentials Prisma schema tests123
Environment & setup
- OS: Ubuntu 20.04.4 LTS
- Docker: Docker version 20.10.12, build 20.10.12-0ubuntu2~20.04.1
- Database: MONGODB
- Node.js version: v16.15.0
Prisma Version
clientVersion: '3.13.0',
meta: {}
Issue Analytics
- State:
- Created a year ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Make the MongoDB Replica Set Requirement Optional in ...
Prisma needs to perform transactions, which requires your MongoDB server to be run as a replica set. Honestly would be really nice if...
Read more >Using Prisma with MongoDB
When using transactions, MongoDB requires replication of your data set to be enabled. To do this, you will need to configure a replica...
Read more >Prisma + MongoDB -> Replica set - Stack Overflow
Prisma needs to perform transactions, which requires your MongoDB server to be run as a replica set. I used Nx (nx.dev) with MongoDB/Express ......
Read more >Lightning Fast Guide on Prisma MongoDB Connection using ...
However, supporting transactions means that we need to have a replica set. There are a couple of ways to solve this. First option...
Read more >How to deploy a MongoDB Replica Set using Docker
I have written a new article about how to deploy a mongodb cluster using a DevOps fashion Style, in this article i am...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Djamilson could you give me a bit more context. Did that setup fix the issue or did you get another issue?
docker-compose.yml
version: ‘3.7’ services:
mongodb_container:
image: prismagraphql/mongo-single-replica:4.4.3-bionic restart: always
volumes: mongo: `