MongoError: This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string

前端 未结 4 641
逝去的感伤
逝去的感伤 2021-01-03 22:05

I am using \"mongoose\": \"^5.7.1\" in my Node.js project. I am making an api which involves updating in two documents. So, I am using the transactions like fol

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-03 22:28

    Transactions are undoubtedly the most exciting new feature in MongoDB 4.0. But unfortunately, most tools for installing and running MongoDB start a standalone server as opposed to a replica set. If you try to start a session on a standalone server, you'll get this error.

    This issue can be resolved by using replica-sets on your local environment.

    I have used run-rs for this purpose.

提交回复
热议问题