微信小程序調(diào)用云函數(shù)報(bào)錯(cuò)Db or Table not exist

調(diào)用失敗 Error: errCode: -404011 cloud function execution error | errMsg: cloud.callFunction:fail requestID 6885a8c3-7483-11ea-9a3c-525400c7e4d7, cloud function service error code -504002, error message errCode: -502005 database collection not exists | errMsg: [ResourceNotFound] Db or Table not exist. Please check your request, but if the problem cannot be solved, contact us.;
Error: errCode: -502005 database collection not exists | errMsg: [ResourceNotFound] Db or Table not exist. Please check your request, but if the problem cannot be solved, contact us.;

這個(gè)錯(cuò)讓我頭大了好久,云數(shù)據(jù)庫(kù)中明明有那個(gè)表,刪了再加也不對(duì),難道遇到鬼了?!

偶然中靈光一閃,意識(shí)到會(huì)不會(huì)和云控制臺(tái)的多個(gè)環(huán)境有關(guān)?于是在網(wǎng)上尋找答案,終于完美解決。解決方法如下:

如果云控制臺(tái)有多個(gè)環(huán)境,在云函數(shù)中初始化的時(shí)候必須指定環(huán)境id,否則,默認(rèn)用第一個(gè)環(huán)境,不管你在開(kāi)發(fā)時(shí)指定的環(huán)境是哪個(gè)!也不管你的app.js中初始化的環(huán)境是哪個(gè)!

cloud.init({ 
  env: cloud.DYNAMIC_CURRENT_ENV
})

唉,感覺(jué)微信的坑好多。。。

我在開(kāi)發(fā)中遇到的更多的坑都已經(jīng)記錄在easyDemo小程序中,希望我的demo能給你easy。我還會(huì)持續(xù)更新easyDemo,歡迎收藏。


easyDemo.jpg
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容