DEV Community

abdulghofurme
abdulghofurme

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)