如何解决数据库事务API提示CloudSDKError的错误?
发布于 5 年前 作者 nachen 5933 次浏览 来自 官方Issues

在使用调用数据库事务API时,一直返回SDKError.

测试代码

错误信息

index.js:37 transaction error CloudSDKError: errCode: -1 unknown error | errMsg: collection.add:fail Error: 
          400 Bad Request
        ; at collection.add api; 
    at returnAsCloudSDKError (C:\...\node_modules\wx-server-sdk\index.js:6057:16)
    at Object.returnAsFinalCloudSDKError (C:\...\node_modules\wx-server-sdk\index.js:6071:15)
    at Promise (C:\...\node_modules\wx-server-sdk\index.js:1201:32)
    at processTicksAndRejections (internal/process/task_queues.js:86:5)
2 回复

给下详细信息 appId, envId 这些? 应该需要升级

升级了一下开发者工具,提示了更多的错误信息,看起来像是mongo数据库版本问题… MongoDB 4.0里也写了同样一句multi-document transactions are not available for sharded cluster

:(

index.js:37 transaction error Error: errCode: -502001 database request fail | errMsg: collection.add:fail [FailedOperation] (Location50841) Multi-document transactions cannot be run in a sharded cluster.; at collection.add api; 
    at returnAsCloudSDKError (:\...\node_modules\wx-server-sdk\index.js605716)
    at Object.returnAsFinalCloudSDKError (:\...\node_modules\wx-server-sdk\index.js607115)
    at C:\...\node_modules\wx-server-sdk\index.js:1201:32
    at processTicksAndRejections (internal/process/task_queues.js85)
回到顶部