prisma requires your MongoDB server to be run as a replica set

If you bump into this error while trying to write to Mongodb, we basically need to setup our mongodb replica set. 
 
Then use the following link below to setup the cluster

 https://www.mongodb.com/compatibility/deploying-a-mongodb-cluster-with-docker 

 On Windows, you may need to make some slight changes to your command to configure your replica set 



Try this - I have replace double quote with single quote near --eval

docker exec -it mongo1 mongosh --eval 'rs.initiate({_id: \"myReplicaSet\", members: [ {_id: 0, host: \"mongo1\"}, {_id: 1, host: \"mongo2\"}, {_id: 2, host: \"mongo3\"} ] })'

After you run command above, you will get a connection string. Use MongoDB compass to try to connect via this connectionstring
 
mongodb://127.0.0.1:27017/directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.10.1


If you're able to connect, you're all set. 


You can start connecting to your database using Primsa. But you also need to change the datasource to Blog or whatever database you're using.

 
mongodb://127.0.0.1:27017/Blog?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.10.1


Optional:- To test

docker exec -it mongo1 mongosh --eval "rs.status()"

Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm