(OperationNotSupportedInTransaction) Cannot create namespace test.application in multi-document transaction 错误的解决方法


MongoDB 中,插入数据时,如果一个 Collection 不存在会先创建 Collection 再插入数据。

但是如果是在一个事务里,就不允许创建新的 Collection事件发生。否则会报错:

(OperationNotSupportedInTransaction) Cannot create namespace testdb.xxx in multi-document transaction.

因此需要提前创建好 Collection:

db.createCollection("xxx")


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM