DEV Community

Abdul Ghofur
Abdul Ghofur

Posted on

Prisma & MongoDB: server to be run as a replica set

Solution for: "Prisma needs to perform transactions, which requires your MongoDB server to be run as a replica set"

Problem

Service & controller sudah dibuat, seharusnya semua aman.
Namun ketika hit API, muncullah Prisma needs to perform transactions, which requires your MongoDB server to be run as a replica set.

Root cause

Error tersebut di atas hanya terjadi pada operasi create, update, dan delete,
karena Prisma perlu MongoDB berjalan sebagai replica set untuk menjalankan operasi-operasi tersebut.

Solution

Edit mongodb.conf

Pastikan /etc/mongod.conf mempunyai code di bawah

replication:
  replSetName: rs0
Enter fullscreen mode Exit fullscreen mode

Restart MongoDB

Restart mongod service setelah perubahan config

sudo systemctl restart mongod
Enter fullscreen mode Exit fullscreen mode

https://abdulghofurme.github.io/posts/prisma-mongodb-server-to-be-run-as-a-replica-set/

Top comments (0)

Billboard image

Try REST API Generation for MS SQL Server.

DevOps for Private APIs. With DreamFactory API Generation, you get:

  • Auto-generated live APIs mapped from database schema
  • Interactive Swagger API documentation
  • Scripting engine to customize your API
  • Built-in role-based access control

Learn more

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay