Home >Web Front-end >JS Tutorial >Prisma & MongoDB: server to be run as a replica set

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

Linda Hamilton
Linda HamiltonOriginal
2024-12-31 16:19:15615browse

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 have been created, everything should be safe.
However, when the API hits, Prisma needs to perform transactions, which requires your MongoDB server to be run as a replica set.

Root causes

The error above only occurs in create, update, and delete operations,
because Prisma needs MongoDB running as replica set to perform those operations.

Solutions

Edit mongodb.conf

Make sure /etc/mongod.conf has the code below

replication:
  replSetName: rs0

Restart MongoDB

Restart mongod service after config
changes

sudo systemctl restart mongod

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

The above is the detailed content of Prisma & MongoDB: server to be run as a replica set. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn