当前位置:网站首页>Wechat applet cloud function batch delete multiple data error: errcode: -502005 database collection not exists
Wechat applet cloud function batch delete multiple data error: errcode: -502005 database collection not exists
2022-07-27 17:51:00 【Can stars count human beings】
Because only one item can be deleted locally , So use the cloud function to delete multiple records , I've been looking for it all day bug, The key is The cloud function compiler does not prompt errors , You can only view by returning content , Make a note of :
Calling cloud functions locally js:
wx.cloud.callFunction({
name: 'lockRemove', // Cloud function name
data: {
orderCode : this.data.orderCode
},success: function(res){
console.log(res); // The return is The result of calling the cloud function , Not the result of cloud function execution
},fail: function(res){
console.log(res);
}
})
Cloud functions :
This place has stepped on many pits by itself :
- First cloud.init : The company has two cloud environments ,app.js A is defined in env, I think there is no need to define , But always if init Not inside env, Will be submitted to the “Error: errCode: -502005 database collection not exists” abnormal .
- Check the document before , Many people write the wrong table name to cause this exception ,collection(‘collectionName’)
- Like the second , Be careful Spelling of words , There are some, like collection Misspelled words , The cloud function has no error prompt ( This is dog blood ), So be sure to check your code .
- Definition cloud、init、datebase Not one less .
- Right click your cloud function folder to see your Cloud environment Is it the same as the definition , If you call a cloud function , No results returned , We have to develop our own cloud – Check whether there are cloud functions uploaded by yourself in the cloud function list , without , Maybe the environment is wrong , Remember to correct .
// Used async await grammar
const cloud = require('wx-server-sdk')
cloud.init({
env: 'br-20210607-0gcoovhi30xxxxx' // This place puts its own cloud function environment
})
const db = cloud.database()
const _ = db.command
exports.main = async (event, context) => {
let {
orderCode
} = event;
console.log(orderCode); // console The result is Development of cloud -- Cloud functions -- Check... In the log
try {
return await db.collection('lock').where({
orderCode: orderCode
}).remove() // Return the result of the call
} catch(e) {
console.error(e)
}
}
If the call succeeds Return the data Pictured :
I've been looking for it all day bug, Mind blowing up , If you have the same problem , There are other exceptions to solve , You can also leave a message to help more cute ~
边栏推荐
- JDBC连接数据库读取前台无法显示数据
- x-sheet 开发教程:初始化配置自定义布局
- VO、DO、DTO、PO是什么
- 树莓派驱动代码的编译和测试
- Switch and router technology-03-basic configuration of switch
- An end-to-end file upload program based on form, including client and server
- numpy数组矩阵操作
- Establishing SSL connection without server‘s identity verification is not recommended
- 交换机和路由器技术-02-以太网交换机工作原理
- 面试好难啊!蚂蚁金服的六轮面试我是强撑过来!差点OUT(面试复盘)
猜你喜欢

ACL 2022 | prompt based automatic depolarization: effectively reducing bias in the pre training language model

一文理解分布式开发中的服务治理

7 岁男孩被 AI 机器人折断手指,仅因下棋太快?

Switch and router technology-02-working principle of Ethernet switch

快解析结合华途文档加密软件

kubernetes 1.24高可用集群二进制部署

JSP自定义标签(下)

笔试缺考者入围教师招聘面试?河南祥符:个别考生成绩统计错误

Zhengzhou University database course resource description

信号量保护之位带操作
随机推荐
General process of background management system permission setting
一文理解分布式开发中的服务治理
(2) CBAM integrated two stream project construction - data preparation
What should we pay attention to when choosing the LED display screen of the stadium
Branch loop statement of C language
数据库超话(一)
Smart fish tank design based on stm32
wallys/DR882-Qualcomm-Atheros-QCA9882-2T2R-MIMO-802.11ac-Mini-PCIe-Wi-Fi-Module-5G-high-power.
数据库超话(二)
Understand the staticarea initialization logic of SAP ui5 application through the initialization of fileuploader
Mlx90640 infrared thermal imager temperature sensor module development notes (VII)
Following the example of IE, is the decline of Firefox inevitable?
Establishing SSL connection without server‘s identity verification is not recommended
详解二叉树之堆
数据库超话(三)
x-sheet 开发教程:初始化配置自定义布局
选择体育场馆的LED显示屏时应该注重哪些方面
初识多态
Dense optical flow extraction dense_ Flow understanding
Switch and router technology-03-basic configuration of switch